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!”.
- ~/.tmux.conf. My
tmuxconfiguration file - ~/.zshrc. My
zshconfiguration file - t. Script to launch
tmux
Sessions
| Command | Description |
|---|---|
| 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 ls | List sessions |
| exit | Exit the session |
Window Management
| Command | Description |
|---|---|
| PREFIX_KEY d | Detach |
| PREFIX_KEY c | New window |
| PREFIX_KEY n | Next window |
| PREFIX_KEY w | List windows |
| PREFIX_KEY , | Rename a window |
Pane Management
| Command | Description |
|---|---|
| PREFIX_KEY % | Split panes vertically (left/right) |
| PREFIX_KEY " | Split panes horizontally (top/bottom) |
| PREFIX_KEY x | Close pane |
| PREFIX_KEY q | Show pane numbers |
| PREFIX_KEY Arrow | Switch between panes |
–