Skip to content

Instantly share code, notes, and snippets.

@jykim16
Forked from MohamedAlaa/tmux-cheatsheet.markdown
Last active April 17, 2018 06:07
Show Gist options
  • Save jykim16/37d461402e5b03a04613ee73048968e2 to your computer and use it in GitHub Desktop.
Save jykim16/37d461402e5b03a04613ee73048968e2 to your computer and use it in GitHub Desktop.
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

list all tmux sessions:

tmux ls

start new with session name:

tmux new -s myname

attach to named:

tmux a -t myname

kill session:

tmux kill-session -t myname

Kill all the tmux sessions:

tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill

Use prefix ctrl+b, then:

Sessions

d  detach
t  big clock
?  list shortcuts
:  prompt
s  list sessions
$  name session

Windows (tabs)

c  create window
w  list windows
n  next window
p  previous window
f  find window
,  name window
&  kill window

Panes (splits)

%  vertical split
"  horizontal split

o  swap panes
q  show pane numbers
x  kill pane
+  break pane into window (e.g. to select text by mouse to copy)
-  restore pane from window
⍽  space - toggle between layouts
<prefix> q (Show pane numbers, when the numbers show up type the key to goto that pane)
<prefix> { (Move the current pane left)
<prefix> } (Move the current pane right)
<prefix> z toggle pane zoom

View

Resizing Panes

You can also resize panes if you don’t like the layout defaults. I personally rarely need to do this, though it’s handy to know how. Here is the basic syntax to resize panes:

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

Copy mode:

PREFIX [ copy mode
ENTER exit copy mode

copying in mouse mode - hold fn key while copying

How to scroll without mouse

Ctrl-b then [ 
then you can use your normal navigation keys to scroll around (eg. Up Arrow or PgDn). 
Press q to quit scroll mode
Function vi
Half page down C-d
Half page up C-u
Next page C-f
Previous page C-b
Scroll down C-Down or C-e
Scroll up C-Up or C-y
Search again n
Search again in reverse N
Search backward ?
Search forward /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment