Top Banner
TMUX Rocks! ( Terminal MUltipleXer ) Kent Chen
67

TMUX Rocks!

Sep 08, 2014

Download

Technology

Kent Chen

TMUX Rocks!
tmux vs. GNU screen
Trick and tips sharing
Some extremely useful lightning fast handy key binding sharing :)
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: TMUX Rocks!

TMUX Rocks! ( Terminal MUltipleXer )

Kent Chen

Page 3: TMUX Rocks!

終端复用器�基本功不談

Not a basic intro course of terminal multiplexer

Page 4: TMUX Rocks!

GNU Screen vs. tmux

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

Page 5: TMUX Rocks!

分享小弟�「跳槽」經驗

An experience sharing after “Jump ship”

(驚)

Page 6: TMUX Rocks!

Screen 用得好好的?

GNU Screen works god damn well?

Page 7: TMUX Rocks!

為什麼要換�tmux

Why switch to tmux?

Page 8: TMUX Rocks!

請各位客倌聽我娓娓道來

Now listen carefully

Page 9: TMUX Rocks!

GNU screen 七宗罪

The SE7EN deadly sins

Page 10: TMUX Rocks!
Page 11: TMUX Rocks!

!

罪宗一�

The 1st deadly sin

Page 12: TMUX Rocks!

Memory eating MONSTER

Sort by MEM%

Page 13: TMUX Rocks!

100 windows in Screen

370 MB residentRef: http://jon.endpoint.com/utosc-2012/screen-vs-tmux-faceoff.html

Page 14: TMUX Rocks!

Ref: http://jon.endpoint.com/utosc-2012/screen-vs-tmux-faceoff.html

100 windows in tmux

5 MB resident

Page 15: TMUX Rocks!

!

罪宗二�

The 2nd deadly sin

Page 16: TMUX Rocks!

Split with 3 window happily

Page 17: TMUX Rocks!

來去猩巴克當個

假文青真碼農Think about coding at Starbucks

Page 18: TMUX Rocks!

體驗文青生活妹也走光寫扣吧

$ screen -x

Reattach to previous session

Page 19: TMUX Rocks!

WTF…

?

?

Page 20: TMUX Rocks!

Restore a session with splitted screen

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

Page 21: TMUX Rocks!

!

罪宗三�

The 3rd deadly sin

Page 22: TMUX Rocks!

Not under active development

A dead project… since 2008

Page 23: TMUX Rocks!

!

罪宗四�

The 4th deadly sin

Page 24: TMUX Rocks!

.

Page 25: TMUX Rocks!

..

Page 26: TMUX Rocks!

...

Page 27: TMUX Rocks!

掰不下去了

Cannot think of more deadly sin

Page 28: TMUX Rocks!

其實還不錯請繼續支持自由軟體

Screen is still pretty excellent Donate Free Software, thanks!

Page 29: TMUX Rocks!

究竟tmux

有何過人之處Why tmux rocks?

Page 30: TMUX Rocks!

極具彈性的Session > Window > Pane

視窗管理Flexible Session / Window / Pane

window management

Page 31: TMUX Rocks!

ScreenshotPane 1 Pane 2

Pane 3

Window

Left status bar Right status bar

Session Name

Session

Page 32: TMUX Rocks!

$ tmux info

Window 1 …Window 2 Window N

Pane Pane Pane Pane

……Client 1 Client 2 Client N

Session

Page 33: TMUX Rocks!

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

Page 34: TMUX Rocks!

client / server model

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

Page 35: TMUX Rocks!

還有什麼特異功能

Any tricks & tips?

Page 36: TMUX Rocks!

!

第靈招�

Tip & Trick 0

Page 37: TMUX Rocks!

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

Page 38: TMUX Rocks!

!

第一招�

Tip & Trick 1

Page 39: TMUX Rocks!

Multiple paste buffers

$ tmux list-buffers <C-b> # !$ tmux paste-buffer <C-b> ]

Page 40: TMUX Rocks!

!

第二招�

Tip & Trick 2

Page 41: TMUX Rocks!

Powerful mouse mode support

Resize Pane

Select Pane[1]

Select Window

1. screen can do “select pane” only

Page 42: TMUX Rocks!

!

第三招�

Tip & Trick 3

Page 43: TMUX Rocks!

Vertical splitting w/o patching

You can patch GNU Screen to do it

It’s pretty useful under 16:9 widescreen

Page 44: TMUX Rocks!

!

第四招�

Tip & Trick 4

Page 45: TMUX Rocks!

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

Page 46: TMUX Rocks!

Pair Programmingwemux: Multi-User Tmux Made Easy

Mode: mirror / pair / rogue

Page 47: TMUX Rocks!

No Magic

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

Page 48: TMUX Rocks!

!

第五招�

Tip & Trick 5

Page 49: TMUX Rocks!

Search in windows

$ tmux find-window <C-b> f

Page 50: TMUX Rocks!

!

第六招�

Tip & Trick 6

Page 51: TMUX Rocks!

Powerline support

• Personal bias … XD

• UTF-8 status line support

https://github.com/erikw/tmux-powerline

Page 52: TMUX Rocks!

!

第七招�

Tip & Trick 7

Page 53: TMUX Rocks!

Synchronize panes

<C-b> : :set synchronize-panes on

Page 54: TMUX Rocks!

!

第八招�

Tip & Trick 8

Page 55: TMUX Rocks!

Highly Scriptable

$ tmux list-commands $ tmux list-keys

Ref: https://gist.github.com/lance/7486428

Page 56: TMUX Rocks!

!

第九招�

Tip & Trick 9

Page 57: TMUX Rocks!

handy tmux_backup.sh

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

Snapshot :

Page 58: TMUX Rocks!

!

第十招�

Tip & Trick 10

Page 59: TMUX Rocks!

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

Page 60: TMUX Rocks!

!

第十一招�

Tip & Trick 11

Page 61: TMUX Rocks!

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

Page 62: TMUX Rocks!

!

第十二招�

Tip & Trick 12

Page 63: TMUX Rocks!

#  Add  in  .tmux.conf  !#  Lightning  fast  pane  movement  w/o  prefix  key  by  <Alt-­‐`>  bind  -­‐n  M-­‐`  select-­‐pane  -­‐t:.+  !#  Lightning  fast  pane  resize  w/o  mouse  mode  by  <Alt-­‐ArrowKey>  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”

Page 64: TMUX Rocks!

!

第十三招�

Tip & Trick 13

Page 65: TMUX Rocks!

#  Add  in  .tmux.conf  !#  Lightning  fast  entering  copy-­‐mode  by  <Alt-­‐c>  #  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  <Alt-­‐H>  /  <Alt-­‐L>  bind  -­‐n  M-­‐H  prev  bind  -­‐n  M-­‐L  next  

Lightening fast key binding (cont.)

Entering copy-mode

Search keyword in scrollback buffer

Page 66: TMUX Rocks!

ReferenceTmux @ 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

Page 67: TMUX Rocks!

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