tmux
"tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen." - man tmux
You can think of it as a replacement for GNU Screen that is more modern.
Examples
Attach to a new session, or open a new session if there is none
Use this shell alias:
alias t="tmux attach || tmux new-session"
Open several named tabs
This example opens named tabs for several hosts and connects to them via ssh. I use a shell script called ssh-stay-connected
which attempts to reconnect to any lost session, otherwise the tab will be closed when the ssh command terminates:
for node in n1 n2 n3 ; do tmux new-window -n "$node" ssh-stay-connected "$node" ; done ;
Links
- https://github.com/tmux/tmux/wiki
- https://github.com/rothgar/awesome-tmux
- https://undeadly.org/cgi?action=article&sid=20090712190402: "Interview with Nicholas Marriott on tmux"
- reptyr: "Reparent a running program to a new terminal." Useful for moving a pid running outside of tmux to running within tmux.