Professional Documents
Culture Documents
start new:
tmux
attach:
attach to named:
tmux a -t myname
list sessions:
tmux ls
kill session:
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
Sessions
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
Sync Panes
You can do this by switching to the appropriate window, typing your Tmux prex (commonly Ctrl-B or Ctrl-A)
and then a colon to bring up a Tmux command line, and typing:
:setw synchronize-panes
You can optionally add on or o to specify which state you want; otherwise the option is simply toggled. This
option is specic to one window, so it wont change the way your other sessions or windows operate. When
youre done, toggle it o again by repeating the command.tip source
Resizing Panes
You can also resize panes if you dont like the layout defaults. I personally rarely need to do this, though its
handy to know how. Here is the basic syntax to resize panes:
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 conguration le to use Vim keys for moving
between windows and resizing panes so we wouldnt have to take our hands o the home row. tmux has a vi
mode for working with the buer as well. To enable it, add this line to .tmux.conf:
setw -g mode-keys vi
With this option set, we can use h, j, k, and l to move around our buer.
To get out of Copy mode, we just press the ENTER key. Moving around one character at a time isnt very
ecient. Since we enabled vi mode, we can also use some other visible shortcuts to move around the buer.
For example, we can use "w" to jump to the next word and "b" to jump back one word. And we can use "f",
followed by any character, to jump to that character on the same line, and "F" to jump backwards on the
line.
Function vi emacs
Back to indentation ^ M-m
Clear selection Escape C-g
Copy selection Enter M-w
Cursor down j Down
Cursor left h Left
Cursor right l Right
Cursor to bottom line L
Cursor to middle line M M-r
Cursor to top line H M-R
Cursor up k Up
Delete entire line d C-u
Delete to end of line D C-k
End of line $ C-e
Goto line : g
Half page down C-d M-Down
Half page up C-u M-Up
Next page C-f Page down
Next word w M-f
Paste buffer p C-y
Previous page C-b Page up
Previous word b M-b
Quit mode q Escape
Scroll down C-Down or J C-Down
Scroll up C-Up or K C-Up
Search again n n
Search backward ? C-r
Search forward / C-s
Start of line 0 C-a
Start selection Space C-Space
Transpose chars C-t
Misc
d detach
t big clock
? list shortcuts
: prompt
Congurations Options:
Resources:
Notes:
Changelog:
Request an Update:
We Noticed that our Cheatsheet is growing and people are coloberating to add new tips and tricks, so please
tweet to me what would you like to add and let's make it better!
Twitter:@MohammedAlaa
Under the Panes section, shouldn't the 'o' key correspond to switch panes and not swap panes?
% is vertical split
" is horizontal
Great cheatsheet!!!
I still don't understand how to resize panes. The default prex is C-b, then what?
" PREFIX : resize-pane -R (Resizes the current pane right) " , I don't get it. Can anyone help? :)
@ehellmanThis confused me too. You need to do C-b then a colon. This will bring up a bar where you can write resize-panes
with whatever ags you want. Good luck!
In tmux-1.8 C-b z does a zoom/maximize of active pane (kind of like your Maximize and restore a pane thingy, i guess).
@goatgThanks for the comment I xed the the pane horizontal and vertical shotcuts
@ehellmanas@nickdtoddexplained the "PREFIX" isctrl+bor depending on your tmux congurations i personally changed
my prex to bectrl+amuch faster :)
:source-file ~/.tmux.conf
Nice!
Awesome!Thanks!
unbind r
bind r source-file ~/.tmux.conf; display "Reloaded"
Thanks. Useful.
It's strange I can't resize the panes in tmux. For example to resize left a pane, I tried:
^b ^h
^b alt-<arrow-left>
^b ^<arrow-left>
This works
^b : resize-pane -L
Any ideas?
I had a problem running your kill-all command as an alias, but I found this one worked well for me:
prefix + ~
Panes (splits)
It's easy to confuse these because if you accidentally keep holding control down from doing your prex then you'll be doing
swap instead of next.
rakgeniuscommentedon 23 Feb 2015
I have problem switching between last used session. C-a L switches to last used window rather than last used session which is
the same as C-a l. Is there a way to switch to last used session?
I'm laughing for myself about the mouse support, like a children with a new lollipop, I just can't believe how AWESOME it is.
When in copy mode I ndShift + jandShift + kvery usefull: text scrolls up/down while maintaining cursor position
Can anyone tell me how to edit current command in tmux? I use vi bindings and want to be able to edit the command I am
currently specifying.
tks
"we set our conguration le to use Vim keys for moving between windows and resizing panes so we wouldnt have to take
our hands o the home row"
One thing you could do to support the growing collaboration is make this a repo instead of a gist.
This /will/ backre for people who use gist ide plugins and tools to quickly access documentation (aka, use gists as a personal
documentation platform), but you could easily setup a CI workow based on webhooks that publishes to the gist when a PR is
merged into the repo.
Then people can do PRs, submit requests via issues, report outdated information via issues, etc, however you wanted to
handle it.
so nice
The kill all sessions didn't work for me, this does:
for sess in $(tmux ls | awk '{FS=":" ; print $1}' | sed 's/://g') ; do tmux kill-session -t $sess ; done
setw -g mode-mouse o
set -g mouse-select-pane o
set -g mouse-resize-pane o
set -g mouse-select-window o
instead use:
*set -g mouse on
Creating a new pane is quite possibly one of the most important controls but I don't see the key commands to do it here?
@Enverexdid you mean splitting current window into multiple panes? SeePanes (splits)
@MohamedAlaaThis sounds like a great set of exercises for shortcutfoo.com's tmux setup. Now that you can create your
own exercises I may have to work o this list to expand my knowledge.
Thanks.
Thank you!
+ break pane into window (e.g. to select text by mouse to copy)is error.
I found this out by mistake, but doing CTRL+D during a tmux session kills it (Very helpful!)
for session in `tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}'`;do tmux kill-session -t ${sessi
Thanks, great cheat sheet. I'm missing a basic shortcut to move between panes. Besidesprefix + oyou can useprefix + the
arrow keysto move up, down, left, right from one pane to the other. It makes you more productive.
ctrl-b esc [1 to 5] moves your current panes to dierent layouts. Which I do all the time due to using IRSSI. Is there a way of
setting your current layout conguration as default?
function tmux_switch_session() {
setxkbmap fr;
xdotool keyup Alt_L && xdotool key "Control_L+b";
xdotool type --clearmodifiers ":a -t $(tmux ls | grep : | cut -d: -f1 | sed -n $($(exit $(tmux ls | wc -l)!=$(tmux ls | g
xdotool key "KP_Enter";
}
zle -N tmux_switch_session;
bindkey "^[s" tmux_switch_session;
Wasn't able to make a tmux shortcut (xdotool sendsCtrl+b, thenls, thenEnter, then:...)
Just want to reiterate@gusgard's comment. The mode for mouse is now simply:setw -g mouse on
this is wrong , you should not treat the tmux session as a normal process,so 'kill' will not work
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
AminaG's solution is correct but luoyuping's killing sessions' way is not working on my remote devserver.
Why not make this a full repo rather than a gist? Then we can send in PRs.
I trapped to this page when googled how to resize panes .this is very usefull. thanks alot
ryrancommentedon 22 Dec 2016
@ryran
thanks for that!
Thanks you!
apurvaguptacommentedon 30 Jan
Is there any way to identify which pane is running what? for example, I am running 10 servers in dierent pane then can I
identify which pane is running what server ?
tonycommentedon 16 Feb
I recently nished a book on tmux,The Tao of tmux. It's available toread on the web for free. The book includes a cheatsheet
section, in addition to covering tmux from the ground up via its session, window and pane objects. I also go into some tricks
for optimizing workows in the world of the terminal. Please feel free to give it a look!
Tony
leotmcommentedon 1 Maredited
Kill all the tmux sessions:tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs killdidn't work
for me.
scutdkcommentedon 18 Maredited
Sync pane is what I am looking for, but it's not so intuitive. Just add a reminder: Sync pane is to duplicate input to any pane to
all other panes in the same window (only for panes that are not in any special mode). Maybe can add this after the title so
even rst timer knows what it means.
One more note, sync pane mode doesn't work in vim. So only way to modify multiple les is to use sed instead.It's working,
just only cursor in the main pane is blinking. :D
LovesThacommentedon 24 Mar
I can't split horizontal, " brings up a list of tmux screens for me, which is rather useless.
cocampbecommentedon 25 Apr
Wholly cow! DO NO USE the kill all tmux sessions shortcut. Your sending tmux session IDs to the kill command. Use this
instead.
smithanagcommentedon 28 Apr
How to search for a text in tmux window?
Siva-Karthicommentedon 19 May
Awesome
deavmicommentedon 26 May
So helpful.
SeattleRexcommentedon 11 Jun
'tmux kill-server' kills all sessions and gives you a fresh start
backwind1233commentedon 12 Jun
very useful
LMtxcommentedon 16 Junedited
@MohamedAlaa
hello, mouse section is outdated - you can update it from my fork
OmarMalikcommentedon 20 Jun
When I have multiple tmux windows open and I resize one, it starts resizing all of them together. How do i disable this? This is
on a mac btw.
0xnurlcommentedon 10 Jul
Shaddycommentedon 6 Aug
This is the bash-script I use when I want to kill all the sessions except the attached.
Not sure why thekill allscript requires grep + cat + awk + xargs, I would write it as this.
Atlas7commentedon 20 Aug
I use this cheatsheet pretty much every single time I use a terminal! Life saver... !
When the window is stuck in a smaller dimension (due to a former session on a smaller screen):
:detach -a