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?
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
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With