Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm following this tutorial for scripting the creation of tmux windows.

tmux new-window t $SESSION:0 -k -n MAIN 'cd ~/main/ && perl -Ilib myapp'

sometimes I kill myapp after I've started tmux, I want to drop back to a shell in that directory, but instead this kills the window entirely. What is the best way to fix this? I think at least one answer involves running a shell and having that shell run commands, but I'm not sure on the best way to accomplish that.

share|improve this question

1 Answer 1

tmux new-window t $SESSION:0 -k -n MAIN 'cd ~/main/ && perl -Ilib myapp; $SHELL'

will launch your default shell when the previous commands have terminated (regardless of their return value, i.e. even if you didn't kill them).

If you only want to drop to the shell if the perl process was killed or failed (and have the tmux window close if it succeeded), use

tmux new-window t $SESSION:0 -k -n MAIN 'cd ~/main/ && perl -Ilib myapp || $SHELL'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.