Skip to content

Instantly share code, notes, and snippets.

@desjardinsm
Forked from henrik/tmux_cheatsheet.markdown
Last active August 29, 2015 14:27
Show Gist options
  • Save desjardinsm/64035c7132a9063faef9 to your computer and use it in GitHub Desktop.
Save desjardinsm/64035c7132a9063faef9 to your computer and use it in GitHub Desktop.
tmux cheatsheet

tmux cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

attach:

tmux a  #  (or at, or attach)

attach to named:

tmux a -t myname

list sessions:

tmux ls

kill session:

tmux kill-session -t myname

In tmux, hit the prefix ctrl+b and then:

Sessions

:new<CR>  new session
s         list sessions
$         name session
d         detach

Windows (tabs)

c           new window
n           next window
p           previous window
,           name window
w           list windows
f           find window
&           kill window
.           move window - prompted for a new number
:movew<CR>  move window to the next unused number

Panes (splits)

%  horizontal split
"  vertical split

o  swap panes
q  show pane numbers
x  kill pane
⍽  space - toggle between layouts
+  break pane into window (e.g. to select text by mouse to copy)
-  restore pane from window
{ (Swap pane with previous pane numerically)
} (Swap pane with next pane numerically)
z toggle pane zoom

Window/pane surgery

:joinp -s :2<CR>  move window 2 into a new pane in the current window
:joinp -t :1<CR>  move the current pane into a new pane in window 1

Sync Panes

:setw synchronize-panes

You can optionally add on or off to specify which state you want; otherwise the option is simply toggled. This option is specific to one window, so it won’t change the way your other sessions or windows operate. When you’re done, toggle it off again by repeating the command. source

Resizing Panes

In addition to these commands, you can also hold down <prefix> and use the arrow keys

:resize-pane -D (Resizes the current pane down)
:resize-pane -U (Resizes the current pane upward)
:resize-pane -L (Resizes the current pane left)
:resize-pane -R (Resizes the current pane right)
:resize-pane -D 20 (Resizes the current pane down by 20 cells)
:resize-pane -U 20 (Resizes the current pane upward by 20 cells)
:resize-pane -L 20 (Resizes the current pane left by 20 cells)
:resize-pane -R 20 (Resizes the current pane right by 20 cells)
:resize-pane -t 2 20 (Resizes the pane with the id of 2 down by 20 cells)
:resize-pane -t -L 20 (Resizes the pane with the id of 2 left by 20 cells)

Copy mode:

Pressing <prefix> [ places us in Copy mode. We can then use our movement keys to move our cursor around the screen. By default, the arrow keys work. we set our configuration file to use Vim keys for moving between windows and resizing panes so we wouldn’t have to take our hands off the home row:

setw -g mode-keys vi

With this option set, we can use h, j, k, and l to move around our buffer. You can view the full list of vi bindings for copy mode with:

:list-keys -t vi-copy

Space        Start selection
Enter        Copy selection
Escape       Clear selection
q            Quit mode
h/j/k/l      Cursor
:            Goto line
C-Down or J  Scroll down
C-Up or K    Scroll up

Misc

t  big clock
?  list shortcuts

Resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment