tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more…
To work with tmux you should understand it’s concepts (pane, window and session) and how shortcuts work.
How tmux shortcuts work
Most of tmux shortcuts consist of prefix and command keys. By default, prefix is
Ctrl-b (shortened as
C-b in future). Command key may be a letter (both upper- and lowercase) or a symbol.
Unlike hotkeys in other apps, you don’t need to keep the prefix key held down while pressing the command key. You press the prefix key, then the command key.
This is the main feature of tmux. When you need a terminal with several windows running different apps (for example: a server, git, and vim), you’d use a few panes.
- Split V:
- Split H:
C-dor the following command:
Windows in tmux is like a tabs. If you need new set of panes, you will create a new window.
- New window:
- Close window:
- Next window:
- Previous window:
- Window by number:
- Rename window:
- Rename current window:
tmux sessions are the interface for using tmux. When you starting a tmux, you staring a tmux session.
- Detach current session:
- Detach session from list:
- List sessions:
- Rename session:
tmux rename-session -t 0 <name>
- Connect to session by number:
tmux attach -t <num>
- Connect to session by name:
tmux attach -s <name>
- Show time:
A user-specific configuration file should be located at
~/.tmux.conf, while a global configuration file should be located at
Here’s some basic options, you’d probably use:
Enable mouse in tmux:
set -g mouse on
Enable colors for Bash:
set -g default-terminal "screen-256color"
Add shortcut for reloading configuration file:
bind r source-file ~/.tmux.conf \; display-message "Configiration file successfully reloaded!"
Change default shell (to fish, for example):
set -g default-command /usr/bin/fish set -g default-shell /usr/bin/fish
Change prefix key from
unbind C-b set -g prefix C-a bind C-a send-prefix
There is alot of other options and shortcuts. You can read more here.
You can also get a cheatsheet, based on this article, from your terminal:
curl -Ls pashinskikh.de/h/tmux