Tmux – the Terminalator


How many times have you ssh into your server, only to have your connection interrupted and your terminal session abruptly closed?  This can be problematic especially if processes are running in the background or you are compiling large programs with many dependencies.  The solution – use tmux, the terminal multiplexer.


Installing tmux:

Always before installing a port from the FreeBSD Ports System, we should update our port tree:

# portsnap fetch update

Next, locating tmux is our next task:

# cd /usr/ports/
# make search name=tmux

From our search results output, tmux is located in /usr/ports/sysutils/tmux:

# make install clean



After the installation of tmux, you can simply invoke a tmux session with the following command:

# tmux

This creates a new session with a unique session name:

# tmux new -s session-name

List all sessions:

# tmux list-sessions

Attach to an existing session:

# tmux attach -t session-name

Detach from a session:

# tmux detach

Switch to another session:

# tmux switch -t session-name

Kill session:

# tmux kill-session -t session-name



Split a session into two vertical panes:

# tmux split-window

Split a session into two horizontal panes:

# tmux split-window -h

Select a specific pane:

# tmux select-pane -[UDLR]

Swap pane with another in a specific direction:

# tmux swap-pane -[UDLR]



Create a new window:

# tmux new-window

Rename current window:

# tmux rename-window

Select a specific window:

# tmux select-window -t :0-9


Other Useful Commands:

Display Information on Sessions, Panes, etc:

# tmux info

List tmux commands and arguments:

# tmux list-commands

List tmux key bindings and commands it runs:

# tmux list-keys



Although there are many commands and arguments, the ones presented above are the most commonly used.  Of course, there are numerous key bindings and configurations which can be modified by utilizing a configurable ~/.tmux.conf file.  Please consult the man page for tmux for the correct command and argument usage, and key bindings.


Additional Resources:

Leave a Reply

Your email address will not be published. Required fields are marked *