Skip to content

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 ;