Slide 1

Slide 1 text

TMUX Rocks! ( Terminal MUltipleXer ) Kent Chen

Slide 2

Slide 2 text

Kent Chen (chenkaie) chenkaie@gmail.com http://chenkaie.blogspot.com @chenkaie on GitHub @chenkaie on SlideShare @chenkaie on LinkedIn @chenkaie on Twitter @+KentChenAtGoogle on Google+

Slide 3

Slide 3 text

終端复用器 基本功 不談 Not a basic intro course of terminal multiplexer

Slide 4

Slide 4 text

GNU Screen vs. tmux Ref: https://www.google.com/trends/explore?q=gnu screen, tmux

Slide 5

Slide 5 text

分享小弟 「跳槽」經驗 An experience sharing after “Jump ship” (驚)

Slide 6

Slide 6 text

Screen 用得好好的? GNU Screen works god damn well?

Slide 7

Slide 7 text

為什麼要換 tmux Why switch to tmux?

Slide 8

Slide 8 text

請各位客倌
 聽我娓娓道來 Now listen carefully

Slide 9

Slide 9 text

GNU screen 七宗罪 The SE7EN deadly sins

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

! 罪宗一 The 1st deadly sin

Slide 12

Slide 12 text

Memory eating MONSTER Sort by MEM%

Slide 13

Slide 13 text

100 windows in Screen 370 MB resident Ref: http://jon.endpoint.com/utosc-2012/screen-vs-tmux-faceoff.html

Slide 14

Slide 14 text

Ref: http://jon.endpoint.com/utosc-2012/screen-vs-tmux-faceoff.html 100 windows in tmux 5 MB resident

Slide 15

Slide 15 text

! 罪宗二 The 2nd deadly sin

Slide 16

Slide 16 text

Split with 3 window happily

Slide 17

Slide 17 text

來去猩巴克 當個 假文青真碼農
 Think about coding at Starbucks

Slide 18

Slide 18 text

體驗文青生活 妹也走光 寫扣吧 $ screen -x Reattach to previous session

Slide 19

Slide 19 text

WTF… ? ?

Slide 20

Slide 20 text

Restore a session with splitted screen Ref: http://superuser.com/questions/69816/how-to-keep- windows-split-after-detaching-reattaching-gnu-screen

Slide 21

Slide 21 text

! 罪宗三 The 3rd deadly sin

Slide 22

Slide 22 text

Not under active development A dead project… since 2008

Slide 23

Slide 23 text

! 罪宗四 The 4th deadly sin

Slide 24

Slide 24 text

.

Slide 25

Slide 25 text

..

Slide 26

Slide 26 text

...

Slide 27

Slide 27 text

掰不下去了 Cannot think of more deadly sin

Slide 28

Slide 28 text

其實還不錯 請繼續支持 自由軟體 Screen is still pretty excellent Donate Free Software, thanks!

Slide 29

Slide 29 text

究竟 tmux 有何過人之處 Why tmux rocks?

Slide 30

Slide 30 text

極具彈性的 Session > Window > Pane 視窗管理 Flexible Session / Window / Pane window management

Slide 31

Slide 31 text

Screenshot Pane 1 Pane 2 Pane 3 Window Left status bar Right status bar Session Name Session

Slide 32

Slide 32 text

$ tmux info Window 1 … Window 2 Window N Pane Pane Pane Pane …… Client 1 Client 2 Client N Session

Slide 33

Slide 33 text

Window 1 … Window 2 Window N Pane Pane Pane Pane Client Session 2 $ tmux choose-session Window 1 Pane Session 1 Window 1 Pane Session 3

Slide 34

Slide 34 text

client / server model Ref: http://bit.ly/tmux-explained

Slide 35

Slide 35 text

還有什麼 特異功能 Any tricks & tips?

Slide 36

Slide 36 text

! 第靈招 Tip & Trick 0

Slide 37

Slide 37 text

No transfer effort from Screen 無痛轉換 i.e. 靈的轉移(驚) My modification: Ref: http://sourceforge.net/p/tmux/tmux-code/ci/master/tree/examples/screen-keys.conf Soul Transfer by: $ alias screen=tmux

Slide 38

Slide 38 text

! 第一招 Tip & Trick 1

Slide 39

Slide 39 text

Multiple paste buffers $ tmux list-buffers # ! $ tmux paste-buffer ]

Slide 40

Slide 40 text

! 第二招 Tip & Trick 2

Slide 41

Slide 41 text

Powerful mouse mode support Resize Pane Select Pane[1] Select Window 1. screen can do “select pane” only

Slide 42

Slide 42 text

! 第三招 Tip & Trick 3

Slide 43

Slide 43 text

Vertical splitting w/o patching You can patch GNU Screen to do it It’s pretty useful under 16:9 widescreen

Slide 44

Slide 44 text

! 第四招 Tip & Trick 4

Slide 45

Slide 45 text

Multiple root-privileged system administrators can share the same session to manage the server. remote SSH w/o leaking your “password” Remote debugging Pair Programming Shared Sessions

Slide 46

Slide 46 text

Pair Programming wemux: Multi-User Tmux Made Easy Mode: mirror / pair / rogue

Slide 47

Slide 47 text

No Magic Ref: http://bit.ly/tmux-explained

Slide 48

Slide 48 text

! 第五招 Tip & Trick 5

Slide 49

Slide 49 text

Search in windows $ tmux find-window f

Slide 50

Slide 50 text

! 第六招 Tip & Trick 6

Slide 51

Slide 51 text

Powerline support • Personal bias … XD • UTF-8 status line support https://github.com/erikw/tmux-powerline

Slide 52

Slide 52 text

! 第七招 Tip & Trick 7

Slide 53

Slide 53 text

Synchronize panes : :set synchronize-panes on

Slide 54

Slide 54 text

! 第八招 Tip & Trick 8

Slide 55

Slide 55 text

Highly Scriptable $ tmux list-commands $ tmux list-keys Ref: https://gist.github.com/lance/7486428

Slide 56

Slide 56 text

! 第九招 Tip & Trick 9

Slide 57

Slide 57 text

handy tmux_backup.sh Ref: http://sourceforge.net/p/tmux/tmux-code/ci/master/tree/examples/tmux_backup.sh Snapshot :

Slide 58

Slide 58 text

! 第十招 Tip & Trick 10

Slide 59

Slide 59 text

PuTTy Fn key issue Terminal > Keyboard > Function Keys and Keypad: “Xterm R6”

Slide 60

Slide 60 text

! 第十一招 Tip & Trick 11

Slide 61

Slide 61 text

Scrollback issue * How can I make tmux use my terminal's scrollback buffer? ! Normally, tmux enables the terminal's "alternate screen". Most terminals (such as xterm) do not save scrollback for the alternate screen. You might prefer tmux to use the normal screen, so it uses your terminal's scrollback buffer. This way, you can access the scrollback buffer as usual, for example using the mouse wheel - although there is no guarantee output inside tmux will always (or ever) be added to the scrollback. ! You can make tmux use the normal screen by telling it that your terminal does not have an alternate screen. Put the following in ~/.tmux.conf: ! set -g terminal-overrides 'xterm*:smcup@:rmcup@' Ref: tmux FAQ http://tmux.svn.sourceforge.net/viewvc/tmux/trunk/FAQ

Slide 62

Slide 62 text

! 第十二招 Tip & Trick 12

Slide 63

Slide 63 text

#  Add  in  .tmux.conf   ! #  Lightning  fast  pane  movement  w/o  prefix  key  by     bind  -­‐n  M-­‐`  select-­‐pane  -­‐t:.+   ! #  Lightning  fast  pane  resize  w/o  mouse  mode  by     bind  -­‐n  M-­‐up        resize-­‐pane  -­‐U  1   bind  -­‐n  M-­‐down    resize-­‐pane  -­‐D  1   bind  -­‐n  M-­‐left    resize-­‐pane  -­‐L  1   bind  -­‐n  M-­‐right  resize-­‐pane  -­‐R  1   Lightening fast key binding “-n”

Slide 64

Slide 64 text

! 第十三招 Tip & Trick 13

Slide 65

Slide 65 text

#  Add  in  .tmux.conf   ! #  Lightning  fast  entering  copy-­‐mode  by     #  Extremely  useful  when  split-­‐pane  are  heavily  used.   bind  -­‐n  M-­‐c  copy-­‐mode   bind  -­‐n  M-­‐PPage  copy-­‐mode  -­‐u   bind  -­‐n  S-­‐PPage  copy-­‐mode  -­‐u   ! #  Lightning  fast  window  select  by    /     bind  -­‐n  M-­‐H  prev   bind  -­‐n  M-­‐L  next   Lightening fast key binding (cont.) Entering copy-mode Search keyword in scrollback buffer

Slide 66

Slide 66 text

Reference Tmux @ Arch Linux wiki https://wiki.archlinux.org/index.php/Tmux Screen vs. tmux Faceoff http://jon.endpoint.com/utosc-2012/screen-vs-tmux-faceoff.html Fixing Vim's Background Color Erase for 256-color tmux http://sunaku.github.io/vim-256color-bce.html How to Copy and Paste with tmux on Mac OS X http://robots.thoughtbot.com/how-to-copy-and-paste-with- tmux-on-mac-os-x

Slide 67

Slide 67 text

Reference cont. wemux: Multi-User Tmux Made Easy https://github.com/zolrath/wemux tmux-powerline https://github.com/erikw/tmux-powerline tmux FAQ http://sourceforge.net/p/tmux/tmux-code/ci/master/tree/FAQ My .tmux.conf https://github.com/chenkaie/DotFiles/blob/master/.tmux.conf