Meet Tmux, an awesome terminal multiplexer. This is one of my favourite command line tools. Easy to use & set up, at the same time powerful; in addition to that it can impress your non-tech friends while you switch dark terminal screens, pretending to be doing some « complicated IT stuff ».
Multiplexer is an application that let you run multiple terminals (or terminal programs) at once, easily switch between them, keep them running in background, etc. To see what it is all about, check this simple Tmux run:
If you like the status bar featured in this episode, check out tmuxified.
Tmux introduces a concept of session which is a group of terminals. When you start Tmux, it creatas its first session. Each session can have several windows i.e. what you see on screen at given time. Windows are numbered. Window can be splitted both horizonatlly or vertically. Each window can have one or several (when splitted) panes that run a terminal.
Tmux has two modes: normal where you enter commands and copy-mode where you can scroll around & copy text.
I changed default prefix key from C-b to C-a. I find it easier to type and it doesn’t conflict with Vim bindings.
unbind C-a ; unbind C-b ; set -g prefix C-a
It is also handy to set up a command sequence for nested Tmux sessions, for example:
bind-key a send-prefix
For a more advanced Tmux configuration example, check out tmuxified.
These are probably the most useful commands in Tmux
- create a new window:
- kill the current window:
- split horizontally:
- split vertically:
- show list of sessions and switch between them:
- show list of windows within the current session:
- copy mode & scroll:
C-a [followed by
Vi or Emacs key bindings: it is how you control Tmux copy-mode.
Automatic Rename: Tmux renames windows automatically using the command name running inside
Live Config Reload: to reload a configuration when inside Tmux, you can simply run:
tmux source-file ~/.tmux.conf
There is a lot more! Check the man and references below to dive into more advanced stuff. Don’t get too much tmuxified though...