tmux logo

tmux is a terminal multiplexer that allows you to have multiple sessions (shells) in a single window. From your Mac, Linux, or even Windows (with WSL) terminal, in a single window you can have multiple active sessions, switch between them, view them simultaneously, enter one and disconnect (they keep running in the background), and reconnect to it in the future.


Installation

On a Mac you can install tmux through HomeBrew


% brew install tmux
% tmux -V

An example with Ubuntu Linux (here you have more options):

% apt install tmux
% tmux -V

On Windows with WSL, search the internet for “windows wsl tmux” and you’ll find multiple references.

Open a new session with new (exit with exit or Ctrl+d).

% tmux new [-s session_name]

To control tmux and tell it to do something, you always need to press the PREFIX KEY first, which by default is Ctrl+b.

<Ctrl+b> + ?               <=== Try it to see all commands

Here are links to my configuration files. I recommend checking out my post “Goodbye Bash, Hello Zsh!”.

Sessions

CommandDescription
tmux [new]New session
tmux new -s [name]Name the session
tmux attach #Start another session in parallel
tmux attach -t [name]Connect to a session
tmux lsList sessions
exitExit the session

Window Management

CommandDescription
PREFIX_KEY dDetach
PREFIX_KEY cNew window
PREFIX_KEY nNext window
PREFIX_KEY wList windows
PREFIX_KEY ,Rename a window

Pane Management

CommandDescription
PREFIX_KEY %Split panes vertically (left/right)
PREFIX_KEY "Split panes horizontally (top/bottom)
PREFIX_KEY xClose pane
PREFIX_KEY qShow pane numbers
PREFIX_KEY ArrowSwitch between panes