Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux window exit when I exit prossess in tmux window

Tags:

tmux

If I have a process like rails c or guard that I exit out of with the command exit the tmux window also exit.

This is not very practical when I just want to restart for example the rail console.

Can I prevent this behavior in tmux?

like image 455
Andreas Lyngstad Avatar asked Mar 24 '23 16:03

Andreas Lyngstad


1 Answers

You can set the remain-on-exit window option to prevent tmux from closing a window (pane) when the process running it ends.

setw remain-on-exit on

The session option set-remain-on-exit is also available; with it you can arrange for all the windows/panes of a session to automatically have remain-on-exit turned on.


After a remain-on-exit pane’s process ends, the pane will display the message “Pane is dead” until it is closed with the command kill-pane (or kill-window), or a new command is started there with respawn-pane (or respawn-window).

respawn-pane 'rails c'     # respawn with a specific command
respawn-pane               # respawn whatever the previous command

If you are not overly concerned about cleanly exiting a pane’s existing process, then you can even restart a pane without first exiting its current process like this:

respawn-pane -k            # kill current process (if any) and respawn the previous command
like image 80
Chris Johnsen Avatar answered Apr 28 '23 09:04

Chris Johnsen