This commit is contained in:
thek4n 2025-11-19 12:40:42 +03:00
parent 81e5d94af7
commit f2dc60ba4d

View File

@ -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}"