diff --git a/home/user/.tmux/example-background-job b/home/user/.tmux/example-background-job index f697f04..965039e 100644 --- a/home/user/.tmux/example-background-job +++ b/home/user/.tmux/example-background-job @@ -1,7 +1,6 @@ #!/bin/sh set -eu -set -m # enable background jobs readonly SESSION=example-background-job readonly MAINW=1 @@ -19,12 +18,7 @@ temp_script="$(mktemp)" readonly temp_script cat > "${temp_script}" << EOF #!/bin/sh - -cleanup() { - rm \$0 # remove self after exit -} - -trap cleanup EXIT +rm \$0 sleep 3 tmux send-keys -t "${SESSION}:${MAINW}.1" 'echo hello' Enter @@ -33,4 +27,4 @@ tmux kill-session -t "${SESSION}" EOF chmod +x "${temp_script}" -nohup "${temp_script}" >/dev/null & # run in background +setsid -f "${temp_script}"