Post on 24-Jan-2018
transcript
Tmux+TMuxinator
GrenobleFLOSSMeetup,16Nov2016
MikeBright, @mjbright
@mjbright
TMux+TMuxinatorWhatisTmuxRelatedtoolsUsingtmux
invokingfromcommand-linekey-bindingstheStatusbartmuxcommandpromptConfiguration
ExtensionsPluginsToolsandsessionmanagement:Tmuxinator
GNUScreenByobuResources
@mjbright
Tmux:AterminalmultiplexerThismeans
youcandetachfromatmuxterminalsessionyoucanreattach,orattachfrommultipleplaces
LikeVNCorRemoteDesktopforterminalsessions
Lostconnectiontoaremoteserverrunningyourtmuxsession?
Yourworkisnotlost,programscontinuetorun
justreconnectsshtotheservertoseerunningtmuxsessions:tmuxlsattachtoasession:tmuxa-t<session>
@mjbright
Buttmuxissomuchmore...
Usetmuxlstoseecurrentlyrunningsessions
@mjbright
Relatedtools...
-tmux : startedin2011,veryactive
-GNUscreen : mucholder,hasmanysimilarfeatures
Byobu|:|Orginallyawrapperaroundscreen,nowtmuxisitsdefaulttmuxinator|:|Rubygemforcomplextmuxlayouts
@mjbright
Basics-Invokingtmuxfromcommand-lineSometmuxcommands
Command
tmuxls : Listcurrentlyrunningsessionstmuxnew : Createanewsessiontmuxnew-n<session> : Createanamedsessiontmuxattach : Attachedtolastactivesessiontmuxattach-t<session> : Attachedtoselectedtarget(e.g.session)tmuxkill-session-t<session> : Deletedselectedsession(careful!)
Sometmuxoptions
Option
-f<conf> : Specifyalternativeuserconffile(else~/.tmux.conf)-L<socket-name> : filenameofserversocketunderTMUX_TMPDIR-S<socket-path> : filepathofserversocket-v : Verboseloggingtotmux-client-PID.log-V : Showtmuxversion@mjbright
Basics-Keybindingswithintmux:SessionsOnceattachedtoatmuxsession,thesessioncanbecontrolledbykeycombinationsstartingwithaprefix'C-b'(ctrl-B)bydefault.
Binding(C-b+...)
? : Help!!$ : Renamethecurrentsession(asseenby'tmuxls')d : DetachfromthecurrentsessionC-z : Suspendthetmuxclientf : Searchforwindowcontainingtext!<Space> : Applynextlayout
@mjbright
Basics-Keybindingswithintmux:WindowsOnceattachedtoatmuxsession,thesessioncanbecontrolledbykeycombinationsstartingwithaprefix'C-b'(ctrl-B)bydefault.
Binding(C-b+...)
, : Renamethecurrentwindowc : Createandmovetoanewwindown : movetothenextwindowp : movetothepreviouswindowl : movetothelastvisitedwindowi : showinfoaboutthecurrentwindow[0-9a-z] : Gotospecfiedwindow
@mjbright
Basics-MoreKeybindingswithintmux:PanesBinding(C-b+...)
z : Showcurrentpaneasfull-screen(C-ztoexit)" : Splitthecurrentpanevertically% : Splitthecurrentpanehorizontally[ : Gointocopymode,allowstoscrollinpane(C-ctoexit)o : Cyclethroughpanesincurrentwindowq : Brieflydisplaypanenumbersx : Killthecurrentpane! : Breakcurrentpaneoutofwindowintoanewone
@mjbright
Basics-ThetmuxstatusbarThestatusbarshowscustomizableinformationaboutthecurrentsession
Bydefaultthisdisplays
currentuser,ipaddress,session-name('0'below)Alistofwindow-names(current-*,withcurrentcommand)
Throughtmux.conf(seelater)wecancustomizeaswewish,forexample:
Notethatifawindowisinfull-screenmodethen'Z'isappendedtothatwindowname
@mjbright
More-KeybindingswithintmuxBinding(C-b+...)
s : Selectanewsessionforthecurrentclient(changesession)t : Showthecurrenttimew : Chooseawindowm :Markthecurrentpane(select-pane-m)M : Unmarkthecurrentpane{ : Swapthecurrentpanewiththepreviouspane} : Swapthecurrentpanewiththenextpane
@mjbright
More-UsingthetmuxcommandpromptBinding(C-b+...)
:setwsynchronize-panes
:Sendkeyboardinputsimultaneoustoallpanesofcurrentwindow
@mjbright
Configuration-Thetmux.conffile(1)Thereareasetoftmuxcommandsaccessiblethroughctrl-B:whichcanalsobeusedinaconfigfile(default~/.tmux.conf)tosettmuxdefaultbehavioursasyouwish.
#SetCtrl-brasshortcuttoreloadthisconfig:bindrsource-file~/.tmux.conf
#Renameterminals:set-gset-titlesonset-gset-titles-string'^#(whoami::#h::#(curlipecho.net/plain;echo)'
#Statusbarcusto:#set-gstatus-utf8onset-gstatus-bgblueset-gstatus-fgwhiteset-gstatus-interval5set-gstatus-left-length90set-gstatus-right-length60set-gstatus-left"#[fg=Green]#(whoami)#[fg=white]::#[fg=blue]\#(hostname-s)#[fg=white]::##[fg=yellow]#(curlipecho.net/plain;echo)"
set-gstatus-justifyleftset-gstatus-right'#[fg=Cyan]#S#[fg=white]%a%d%b%R'
@mjbright
Configuration-Thetmux.conffile(2)usectrl-barrows-Panenavigationwithvim-bindings:
unbind-keyj;bind-keyjselect-pane-Dunbind-keyk;bind-keykselect-pane-Uunbind-keyh;bind-keyhselect-pane-Lunbind-keyl;bind-keylselect-pane-R
@mjbright
ToolsandsessionmanagementTools
powerlineStatuslinepluginforvim,andprovidesstatuslinesandpromptsforseveralotherapplicationsincludingtmux
tmux-cssh TMUXwitha"ClusterSSH"-likebehaviour
tmuxifierTmuxifyyourTmux.Powerfulsession,window&panemanagementforTmux.
tmuxinator Managecomplextmuxsessionseasilytmuxomatic Intelligenttmuxsessionmanagementtmuxp tmuxsessionmanagerandpythonlibrary
@mjbright
Toolsandsessionmanagement:TmuxinatorTmuxinatorallowstoeasilymanagecomplextmuxsessionswithmultiplewindows,paneswithaspecifiedlayoutallspecifiedinaYAMLfile:
project_name:8paneswindows:
shell:layout:a506,379x84,0,0{125x84,0,0[125x26,0,0,4,125x31,0,27,83,125x25,0,59,82],125x84,126,0[125x42,126,0,79,125x41,126,43,86],127x84,252,0[127x27,252,0,80,127x30,252,28,84,127x25,252,59,85]}panes:
-bannerpane1-bannerpane2-bannerpane3-bannerpane4-bannerpane5-bannerpane6-bannerpane7-bannerpane8
@mjbright
Toolsandsessionmanagement:Tmuxinator-2windows:
work:layout:tiledpanes:
-messages:-exec~/z/bin/Deployed/ssh_tunnel_b10.shwork-sudotail-f/var/log/messages-shell:-exec~/z/bin/Deployed/ssh_tunnel_b10.shwork-exec~/z/bin/Deployed/ssh_tunnel_b10.shwork
b1machines:layout:tiledpanes:
-b0g1_logs:-exec~/z/bin/Deployed/ssh_tunnel_b10.shb0g1-banner$(hostname)-uptime;ipa|grep10.3.222-cd/var/log-sudotail-fsyslog-b1g1_logs:-exec~/z/bin/Deployed/ssh_tunnel_b10.shb1g1-banner$(hostname)
@mjbright
Toolsandsessionmanagement:Tmuxinator-3name:perfsroot:~/windows:
perfs:layout:main-horizontalroot:~/tmppanes:
-htop:htop-sensors:~/z/bin/Deployed/perf_monitor_CPUtrend.sh
@mjbright
GNUScreen
https://www.gnu.org/software/screen/
Screenisafull-screenwindowmanagerthatmultiplexesaphysicalterminalbetweenseveralprocesses,typicallyinteractiveshells.
WhilsttmuxisamoreactiveprojectScreenalreadyhasmanyofthesamefeatures,suchas:
sessioncontinuesindetachedmodewhennoclientisconnectedhasaprefixkeyforenteringcommands
ItusesCtrl+Athough(tmuxchosetobedifferent)multiplewindowsabilitytolistwindowsorcreatethemonthefly,switchwindowsabilitytosplitwindowshorizontallyorvertically...
IfGNUScreenworksforyou...keepit...@mjbright
Byobu
http://byobu.co/
ByobuisaGPLv3opensourcetext-basedwindowmanagerandterminalmultiplexer.
Itwasoriginallydesignedtoprovideelegantenhancementstotheotherwisefunctional,plain,practicalGNUScreen,fortheUbuntuserverdistribution.
Byobunowincludesanenhancedprofiles,convenientkeybindings,configurationutilities,andtoggle-ablesystemstatusnotificationsforboththeGNUScreenwindowmanagerandthemoremodernTmuxterminalmultiplexer,andworksonmostLinux,BSD,andMacdistributions.
@mjbright
ResourcesTmux
homepagehttps://tmux.github.io/sourcehttps://github.com/tmux/tmuxawesome-tmux:awesome-tmuxOfficialtmux-plugins:tmux-plugins
TMuxinator:https://github.com/tmuxinator/tmuxinator
GNUScreen:https://www.gnu.org/software/screen/
Byobu:http://byobu.co/
@mjbright