Tmux Cheat Sheet
Tmux Cheat Sheet
SignupforaGitHubaccount
Instantlysharecode,notes,andsnippets.
Signin
Createagistnow
MohamedAlaa / tmuxcheatsheet.markdown
Lastactive6hoursago
tmuxshortcuts&cheatsheet
tmuxcheatsheet.markdown
tmuxshortcuts&cheatsheet
startnew:
tmux
startnewwithsessionname:
tmuxnewsmyname
attach:
tmuxa#(orat,orattach)
attachtonamed:
tmuxatmyname
listsessions:
tmuxls
killsession:
tmuxkillsessiontmyname
Killallthetmuxsessions:
tmuxls|grep:|cutd.f1|awk'{printsubstr($1,0,length($1)1)}'|xargskill
Intmux,hittheprefix
ctrl+b
(mymodifiedprefixisctrl+a)andthen:
Sessions
:new<CR>newsession
slistsessions
$namesession
Windows(tabs)
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
1/10
04/02/2016
ccreatewindow
wlistwindows
nnextwindow
ppreviouswindow
ffindwindow
,namewindow
&killwindow
Panes(splits)
%verticalsplit
"horizontalsplit
oswappanes
qshowpanenumbers
xkillpane
+breakpaneintowindow(e.g.toselecttextbymousetocopy)
restorepanefromwindow
spacetogglebetweenlayouts
<prefix>q(Showpanenumbers,whenthenumbersshowuptypethekeytogotothatpane)
<prefix>{(Movethecurrentpaneleft)
<prefix>}(Movethecurrentpaneright)
<prefix>ztogglepanezoom
SyncPanes
Youcandothisbyswitchingtotheappropriatewindow,typingyourTmuxprefix(commonlyCtrlBorCtrlA)andthenacolon
tobringupaTmuxcommandline,andtyping:
:setwsynchronizepanes
Youcanoptionallyaddonorofftospecifywhichstateyouwantotherwisetheoptionissimplytoggled.Thisoptionisspecific
toonewindow,soitwontchangethewayyourothersessionsorwindowsoperate.Whenyouredone,toggleitoffagainby
repeatingthecommand.tipsource
ResizingPanes
Youcanalsoresizepanesifyoudontlikethelayoutdefaults.Ipersonallyrarelyneedtodothis,thoughitshandytoknow
how.Hereisthebasicsyntaxtoresizepanes:
PREFIX:resizepaneD(Resizesthecurrentpanedown)
PREFIX:resizepaneU(Resizesthecurrentpaneupward)
PREFIX:resizepaneL(Resizesthecurrentpaneleft)
PREFIX:resizepaneR(Resizesthecurrentpaneright)
PREFIX:resizepaneD20(Resizesthecurrentpanedownby20cells)
PREFIX:resizepaneU20(Resizesthecurrentpaneupwardby20cells)
PREFIX:resizepaneL20(Resizesthecurrentpaneleftby20cells)
PREFIX:resizepaneR20(Resizesthecurrentpanerightby20cells)
PREFIX:resizepanet220(Resizesthepanewiththeidof2downby20cells)
PREFIX:resizepanetL20(Resizesthepanewiththeidof2leftby20cells)
Copymode:
PressingPREFIX[placesusinCopymode.Wecanthenuseourmovementkeystomoveourcursoraroundthescreen.By
default,thearrowkeyswork.wesetourconfigurationfiletouseVimkeysformovingbetweenwindowsandresizingpanes
sowewouldnthavetotakeourhandsoffthehomerow.tmuxhasavimodeforworkingwiththebufferaswell.Toenableit,
addthislineto.tmux.conf:
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
2/10
04/02/2016
setwgmodekeysvi
Withthisoptionset,wecanuseh,j,k,andltomovearoundourbuffer.
TogetoutofCopymode,wejustpresstheENTERkey.Movingaroundonecharacteratatimeisntveryefficient.Sincewe
enabledvimode,wecanalsousesomeothervisibleshortcutstomovearoundthebuffer.
Forexample,wecanuse"w"tojumptothenextwordand"b"tojumpbackoneword.Andwecanuse"f",followedbyany
character,tojumptothatcharacteronthesameline,and"F"tojumpbackwardsontheline.
Functionviemacs
Backtoindentation^Mm
ClearselectionEscapeCg
CopyselectionEnterMw
CursordownjDown
CursorlefthLeft
CursorrightlRight
CursortobottomlineL
CursortomiddlelineMMr
CursortotoplineHMR
CursorupkUp
DeleteentirelinedCu
DeletetoendoflineDCk
Endofline$Ce
Gotoline:g
HalfpagedownCdMDown
HalfpageupCuMUp
NextpageCfPagedown
NextwordwMf
PastebufferpCy
PreviouspageCbPageup
PreviouswordbMb
QuitmodeqEscape
ScrolldownCDownorJCDown
ScrollupCUporKCUp
Searchagainnn
Searchbackward?Cr
Searchforward/Cs
Startofline0Ca
StartselectionSpaceCSpace
TransposecharsCt
Misc
ddetach
tbigclock
?listshortcuts
:prompt
ConfigurationsOptions:
#Mousesupportsettoonifyouwanttousethemouse
*setwgmodemouseoff
*setgmouseselectpaneoff
*setgmouseresizepaneoff
*setgmouseselectwindowoff
#Setthedefaultterminalmodeto256colormode
setgdefaultterminal"screen256color"
#enableactivityalerts
setwgmonitoractivityon
setgvisualactivityon
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
3/10
04/02/2016
#Centerthewindowlist
setgstatusjustifycentre
#Maximizeandrestoreapane
unbindUpbindUpnewwindowdntmp\swappanestmp.1\selectwindowttmp
unbindDown
bindDownlastwindow\swappanestmp.1\killwindowttmp
Resources:
tmux:ProductiveMouseFreeDevelopment
Howtoreorderwindows
Notes:
Changelog:
1411143833002AddedtogglezoomunderPanes(splits)section.
1411143833002AddedSyncPanes
1414276652677AddedKillalltmuxsessions
1438585211173correctedcreateandaddnextandpreviusthanksto@justinjhendrick
RequestanUpdate:
WeNoticedthatourCheatsheetisgrowingandpeoplearecoloberatingtoaddnewtipsandtricks,sopleasetweettome
whatwouldyouliketoaddandlet'smakeitbetter!
Twitter:@MohammedAlaa
ravooricommentedon18Apr2013
UnderthePanessection,shouldn'tthe'o'keycorrespondtoswitchpanesandnotswappanes?
goatfigcommentedon21Apr2013
%isverticalsplit
"ishorizontal
Greatcheatsheet!!!
ehellmancommentedon22Apr2013
Istilldon'tunderstandhowtoresizepanes.ThedefaultprefixisCb,thenwhat?
"PREFIX:resizepaneR(Resizesthecurrentpaneright)",Idon'tgetit.Cananyonehelp?:)
nickdtoddcommentedon24Apr2013
@ehellmanThisconfusedmetoo.YouneedtodoCbthenacolon.Thiswillbringupabarwhereyoucanwriteresizepaneswithwhatever
flagsyouwant.Goodluck!
rawzonecommentedon2Jul2013
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
4/10
04/02/2016
MohamedAlaacommentedon11Aug2013
Owner
@goatfigThanksforthecommentIfixedthethepanehorizontalandverticalshotcuts
MohamedAlaacommentedon11Aug2013
Owner
@ehellmanas@nickdtoddexplainedthe"PREFIX"is
ctrl+b
ordependingonyourtmuxconfigurationsipersonallychangedmyprefixto
be
ctrl+a
muchfaster:)
todgrucommentedon16Aug2013
Reloadthetmuxconfigfilefromshell:
$tmuxsourcefile~/.tmux.conf
Orfromtmuxcommandline:
:sourcefile~/.tmux.conf
Atcoldcommentedon22Nov2013
Awesome!Thanksindeedforthesetips!
anthonybrowncommentedon9Dec2013
Nice!
bernardrcommentedon29Dec2013
Awesome!Thanks!
MohamedAlaacommentedon1Jan2014
Owner
@todgruIpersonallyhaveinmy.tmux.conf
unbindr
bindrsourcefile~/.tmux.confdisplay"Reloaded"
thiswaywheniusethe
PREFIX+r
itloads
joestringercommentedon7Feb2014
Resizingdownseemstorequirethe"D"optionforme(tmux1.6):
PREFIX:resizepaneD20(Resizesthecurrentpanedownby20cells)
kocsenccommentedon11Feb2014
Useiteveryday.AmazingCheatsheet
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
5/10
04/02/2016
thanks!helpedalot:)
tdoumascommentedon22Mar2014
Thankyou!Veryuseful
bradleyankromcommentedon2Jun2014
Lookslikethecheatsheetlinkisdead:(http://cheat.errtheblog.com/s/tmux/
MohamedAlaacommentedon4Jun2014
Owner
thanks@bradleyankromIremovedthelinktothecheat:)
i90rrcommentedon21Jun2014
Runningtmux1.8,samebehaviourasdescribedby@joestringer:
"Resizingdownseemstorequirethe"D"optionforme"
Btw,nicelisttohaveathand:)
benoptimuscommentedon8Jul2014
thankyouforsharingthis,veryuseful!!
rushiagrcommentedon12Jul2014
Thanks.Useful.
gavsimcommentedon14Jul2014
Veryuseful,greatlyappreciated.
giangnguyennetcommentedon20Jul2014
It'sstrangeIcan'tresizethepanesintmux.Forexampletoresizeleftapane,Itried:
^b^h
^balt<arrowleft>
^b^<arrowleft>
Thisworks
^b:resizepaneL
butIpreferashortcuttohavingtotypetoomuch.
Anyideas?
ps:Idon'thave~/.tmux.conffile
fkenjicommentedon12Aug2014
@ndgiang84IfyouareonMacOSyoucantrythisout:http://superuser.com/questions/660013/resizingpaneisnotworkingfortmuxonmac
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
6/10
04/02/2016
Thankforyourtips.
Btw,howcanIchangethedefaultPREFIX(CTRL+B)toanotherkey?
Drive137commentedon13Aug2014
@hlenvdyoucanIdo
setoptiongprefixCa
unbindCb
bindkeyCasendprefix
inthetmux.config
sourcehttp://robots.thoughtbot.com/atmuxcrashcourse
toorehtcommentedon18Aug2014
Thankyouforthisawsomecheatsheet!
Whataboutadding@rawzone'szoomcommandtothePanessection?
ztoggle(zoom)activepanetofullterminalsize
MohamedAlaacommentedon20Sep2014
Owner
UpdatedThefollowing
Addedthetogglezoomcommand
AddedTheSyncPanestrick
Youaskforupdatedbysendingmeatweet@MohammedAlaa
MohamedAlaacommentedon26Oct2014
Owner
UpdatedThefollowing
Addedkillalltmuxsessions
Youaskforupdatedbysendingmeatweet@MohammedAlaa
MrWonderfulcommentedon28Oct2014
Ihadaproblemrunningyourkillallcommandasanalias,butIfoundthisoneworkedwellforme:
aliastmkill='while[$?ne1]dotmuxkillsessiondone'
quizzmastercommentedon5Nov2014
Toresizeapanedown:
PREFIX:resizepaneD20(Resizesthecurrentpanedownby20cells)
shropcommentedon8Dec2014
BestcheatsheetfortmuxIhaveseen.Postedonhttp://shelldevel.net/post/104491784292/mohamedalaatmuxcheatsheetmarkdown
wbinnscommentedon10Jan2015
Thanksforputtingthistogether.:)
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
7/10
04/02/2016
nooitafcommentedon18Jan2015
Showalistofthemessagestmuxdisplayedinthelowerbar:
prefix+~
jacktasiacommentedon19Feb2015
Panes(splits)
oswitchtonextpane
Coswappanes
It'seasytoconfusethesebecauseifyouaccidentallykeepholdingcontroldownfromdoingyourprefixthenyou'llbedoingswapinsteadof
next.
rakgeniuscommentedon24Feb2015
Ihaveproblemswitchingbetweenlastusedsession.CaLswitchestolastusedwindowratherthanlastusedsessionwhichisthesameasC
al.Isthereawaytoswitchtolastusedsession?
bobeirasacommentedon20Apr2015
I'mlaughingformyselfaboutthemousesupport,likeachildrenwithanewlollipop,Ijustcan'tbelievehowAWESOMEitis.
nladdcommentedon8May2015
Thanks!ExactlywhatIneeded
LukasMaccommentedon16May2015
WhenincopymodeIfind
Shift+j
and
Shift+k
veryusefull:textscrollsup/downwhilemaintainingcursorposition
VladSemcommentedon23May2015
justtypeinterminalmantmux
zaynetrocommentedon16Jul2015
Cananyonetellmehowtoeditcurrentcommandintmux?IusevibindingsandwanttobeabletoeditthecommandIamcurrentlyspecifying.
thuannvncommentedon20Jul2015
tks
justinjhendrickcommentedon29Jul2015
Considertheseedits?https://gist.github.com/justinjhendrick/51dcf569322675ceeacf
Ichanged"newwindow"to"createwindow",sothatit'seasiertoremember.
Iadded"nextwindow"and"previouswindow".
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
8/10
04/02/2016
grahamgcommentedon4Aug2015
ThanksforthisgreatreferencesheetMohamed!
j0hnsmithcommentedon15Sep2015
Greatcheatsheet,somethingismissing...
"wesetourconfigurationfiletouseVimkeysformovingbetweenwindowsandresizingpanessowewouldnthavetotakeourhandsoffthe
homerow"
Canyouaddthat?
fuzzyweaponcommentedon17Sep2015
Onethingyoucoulddotosupportthegrowingcollaborationismakethisarepoinsteadofagist.
This/will/backfireforpeoplewhousegistidepluginsandtoolstoquicklyaccessdocumentation(aka,usegistsasapersonaldocumentation
platform),butyoucouldeasilysetupaCIworkflowbasedonwebhooksthatpublishestothegistwhenaPRismergedintotherepo.
ThenpeoplecandoPRs,submitrequestsviaissues,reportoutdatedinformationviaissues,etc,howeveryouwantedtohandleit.
chenqingcommentedon17Sep2015
sonice
ttpearscommentedon20Oct2015
Thekillallsessionsdidn'tworkforme,thisdoes:
forsessin$(tmuxls|awk'{FS=":"print$1}'|sed's/://g')dotmuxkillsessiont$sessdone
retrautcommentedon22Oct2015
Thxforthat
gusgardcommentedon4Nov2015
InConfigurationsOptions.Tmux2.1dontsupport
setwgmodemouseoff
setgmouseselectpaneoff
setgmouseresizepaneoff
setgmouseselectwindowoff
insteaduse:
*setgmouseon
Enverexcommentedon13Nov2015
CreatinganewpaneisquitepossiblyoneofthemostimportantcontrolsbutIdon'tseethekeycommandstodoithere?
ChiChoucommentedon15Nov2015
@Enverexdidyoumeansplittingcurrentwindowintomultiplepanes?SeePanes(splits)
dragon788commentedon20Nov2015
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
9/10
04/02/2016
AbhimanyuAryancommentedon23Nov2015
Thanks.
dautovricommentedon23Dec2015
Thankyou!
Ryan4021commentedon30Dec2015
Thisisgreat,thanks!
marzkcommented22daysago
+breakpaneintowindow(e.g.toselecttextbymousetocopy)
iserror.
!Breakthecurrentpaneoutofthewindow.
tmux
FrozenBeardcommented9daysago
Ifoundthisoutbymistake,butdoingCTRL+Dduringatmuxsessionkillsit(Veryhelpful!)
tiborsimoncommented3daysago
PREFIX:resizepanetL20(Resizesthepanewiththeidof2leftby20cells)
Didn'tyoumissthepaneidafterthe
t
?
Signupforfree
tojointhisconversationonGitHub.Alreadyhaveanaccount?Signintocomment
https://gist.github.com/MohamedAlaa/2961058#file-tmux-cheatsheet-markdown
10/10