tmux
Est. read time: 2 minutes | Last updated: November 07, 2024 by John Gentile
Contents
Overview
tmux
is a useful terminal program to multiplex and organize multiple applications or workflows while maintating speed and efficiency of “mouse-free” environment. tmux
can be installed with most package managers or built from source. To see if tmux
is already installed, and if so what version, run
$ tmux -V
.
Command Prefix
It’s important to note that most operations are controlled by a specific Prefix key combination (by default this is Ctrl+b) followed by another key or combination of keys.
Launching, Attaching & Sessions
tmux
can be simply launched with either a sole command or with a new, defined session name:
A new session can also be launched with Prefix, :new<CR>
. Prefix, $ can name the current session.
To see currently open sessions hit Prefix, s or run:
To detach from a session, hit Prefix, d.
Then to (re)attach to a certain session, you can attach to a certain session number or session name:
Finally to kill/end a certaion session, the same applies:
Windows & Panes
Windows in tmux
are similar to tabs in web browsers and are useful for seperating distinct workflows or applicaiton sets. Panes are individual panels that can split or divide the space within a window and are useful for seperating similar applications or for multitasking several operations within a workflow.
Again note that the below key shortcuts are controlled by a Prefix key combination (by default this is Ctrl+b) followed by the stated key or combination of keys. The default key-bindings are listed below but are commonly changed through a configuration file .tmux.conf.
Window Shortcuts
Operation | Key(s) | Description |
---|---|---|
Create New Window | c | Creates new window in a tmux session |
Name Current Window | , | |
List/Select Window(s) | w | Lists currently opened windows in session and a user can change to another window by selecting a given window in the list and hitting Enter |
Jump to Window # | 0...9 | Jumps to window numbered 0 through 9; if more than 10 windows exist a desired window can be found with the below command |
Find Window | f | Performs a search of currently opened windows and, if the window is found, switches to the matched window |
Move Window | . | Moves window to a new window order number. Prefix, :movew<CR> moves current window to the next unused window number |
Kill Window | & | Kills currently opened window. Closing a terminal session with $ exit in the last pane of a window has the same effect |
Pane Shortcuts
Operation | Key(s) | Description |
---|---|---|
Split Horizontal | % | Splits a currently active window or pane horizontally in the middle creating another pane below |
Split Vertical | " | Splits a currently active window or pane vertically in the middle creating another pane to the right |
Toggle Layout | Space | Toggles a current set of windows between a horizontal and vertical split |
Switch Neighbor Panes | o | Switches active context to other open neighboring pane |
Move Around Panes 2D | ←/↑/→/↓ | Move active context around panes in window |
Swap Panes | {/} | Swap current pane with either pane one index above ({) or pane one index below (}) |
Show Pane Numbers | q | Shows assigned pane numbers for currently active window |
Maximize Current Pane | z | Maximizes the current pane but retains information from previous layout. Hitting this keystroke again toggles the feature and causes the pane and layout to return to previous |
Kill Pane | x | Kills currently active pane. Closing a terminal session with $ exit in the current pane has the same effect |
Miscellaneous
Operation | Key(s) | Description |
---|---|---|
Show Big Clock | t | |
List Shortcuts | ? | Show currently assigned shortcuts |
tmux Prompt |
: | Bring up the prompt for entering commands to tmux |
Text Manipulation
Operation | Key(s) | Description |
---|---|---|
Enter Copy Mode | Prefix, [ | Moves tmux into copy mode |
Select Text | space, select text, Enter | Once space is hit, tmux enters a mode similar to Vim’s visual mode where text can be selected with arrow keys or vim navigation keybindings. Once text is selected, hit Enter to copy text to tmux ’s buffer and can be pasted in another pane or window |
Paste from tmux Buffer |
Prefix, ] | Pastes previously copied text at cursor |
Customization
tmux
, like Vim
and other useful tools, can be configured with custom preferences with a config file; the file .tmux.conf
can be placed in the user’s home directory to configure things like keybindings, status bar and other aesthetic features. An example dotfile for tmux
can be found here.
There are also projects like tmux plugin manager that can install and maintain tmux plugins & extra features.
Scripting
tmux
operations can also be scripted to create a standard environment with easy launching.