Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop tmux detached session closing when command finishes

Tags:

tmux

When I fire up a new, detached tmux session using something like

tmux new-session -d -s "newname" 'python my file.py'

the tmux session seems to disappear from tmux ls once my python program has finished. I'd like to drop back into a shell. How do I do that?

like image 610
user2667066 Avatar asked Oct 23 '25 16:10

user2667066


1 Answers

Use send-keys to run your script in the default shell process in the new window.

tmux new-session -d -s "new name"
tmux send-keys -t "new name:0" "python my file.py" Enter
like image 141
chepner Avatar answered Oct 27 '25 07:10

chepner