Show Menu
Cheatography

Tmux basics Cheat Sheet by

Are you a heavy command line user? Do you long long-running jobs via the terminal that you don't want to accidentally close even if you lose your connection? If so, tmux is for you!

General Controls

ctrl+b
Default Bind Key
bind-key ?
Lists bind-key combin­ations
bind-key :
Enter config options directly for current session

Tmux Sessions

tmux
start tmux and attach to default session
tmux ls
prints a list of existing tmux sessions
tmux new -s <na­me>
Create a new named tmux session
tmux a -t <na­me>
Attach to a named tmux session
tmux kill-s­ession -t <na­me>
Kill a session when you're done with it
bind-key, $
(Re)Name a session

256 Color support

Add
alias tmux="T­ERM­=sc­ree­n-2­56c­olo­r-bce tmux"
to your /.bash­_pr­ofile and
set -g defaul­t-t­erminal "­xte­rm"
to
/.tmux.conf

Other useful config file tricks

set-option -g pane-a­cti­ve-­bor­der-fg <co­lor>
Surround the active pane with a specific color for easier identi­fic­ation
bind '"' split-­window -c "­#{p­ane­_cu­rre­nt_­pat­h}"
When splitting a pane horizo­ntally, create the new pane from the current directory
bind % split-­window -h -c "­#{p­ane­_cu­rre­nt_­pat­h}"
When splitting a pane vertic­ally, create the new pane from the current cirectory
bind c new-window -c "­#{p­ane­_cu­rre­nt_­pat­h}"
When creating a new window , create from the current directory.
bind-key R source­-file /.tmux.conf; displa­y-m­essage "/.tmux.conf is reload­ed"
Allows you to bind-key R to reload your tmux config for the current session
setw -g monito­r-a­ctivity on
Allows tmux to monitor for comman­d/p­rocess exits
set -g visual­-ac­tivity on
When a command exits in a non-active window, visually change the tab list to reflect that
These go in ~/.tmu­x.conf
 

Windows / Tabs -

bind-key c
Create a new window/tab
bind-key w
List windows­/tabs (helps on smaller screens)
bind-key ,
(Re)Name a window/tab
bind-key &
Kill current window (confi­rmation req)
bind-key <nu­mbe­r>
Go directly to numbered window
bind-key l
Last Active window/tab
bind-key n
Next window/tab
bind-key
Previous window
In the status bar (bottom) are the number­s/names of window­s/tabs.

Panes (verti­cal­/ho­riz­ontal splits)

bind-key %
Split current pane vertically
bind-key "
Split current pane horizo­ntally
bind-key q
Show numeric pane values (red is active)
bind-key o
Cycle through panes
bind-key x
Kill current pane (req confir­mation)
bind-key !
Close all panes except current (req conf)
bind-key +
Break pane into new tab/window
bind-key -
Restore pane from new tab to old tab
bind-key <arrow keys>
Navigate around panes
There are many other key-bi­ndings for resizing panes that are worth learning, but out of scope for a basic cheats­heet. Using the mouse modes for resizing is also helpful.

Mouse Support

setw -g mode-mouse on
enable mouse integr­ation
setw -g mouse-­sel­ect­-pane on
use the mouse to select panes
setw -g mouse-­res­ize­-pane on
use the mouse to resize panes
setw -g mouse-­sel­ect­-window on
use the mouse to select window­s/tabs
These go in ~/.tmu­x.conf
           
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          tmux the terminal multiplexer Cheat Sheet
          tmux - terminal multiplexer Keyboard Shortcuts
          Tmux Cheat Sheet