Table of contents


tmux是可以讓 ssh 的畫面分割成多個獨立的工作區域的指令,效果如下圖

img

基本功能

啟動鍵(bind-key) : ctrl + b (預設)
help            : ctrl + b  ?

window操作

建立window後,可以在 command bar上看到目前有幾個window

新增一個window        : ctrl + b  c
切換到window n        : ctrl + b  n  (n = 0...9)


panel操作

window v.s panel : 一個切割過的完整畫面叫做一個window,window可被切個成多個區塊,每個區塊稱為panel。 tmux可以有多個window,每個windows可以有多個panel

水平分割          : ctrl + b  "
重直分割          : ctrl + b  % 
顯示panel代號     : ctrl + b  q (畫面會顯示panel代號後,可按代號切換到該panel)
切換到上一個panel  : ctrl + b  ; 

copy & paste

  1. 先用 ctrl + b [ 進入copy mode
  2. 用hjkl移動到要copy的起點
  3. 按space開始標記copy的內容
  4. 用hjkl標記選取範圍
  5. 選取完畢後,按enter進行copy
  6. 按 ctrl + b ] 把buffer裡的內容貼到目前位置(中間一樣可以做其他操作,ex:切換到另一個panel)

tmux固定畫面大小,沒辦法做 scrolling up/down,但可以利用進入 copy mode,就可以上下移動的特性來查被捲到前面的訊息

完整的keymap

bind-key        C-b send-prefix                                                                             [40/40]
bind-key        C-o rotate-window
bind-key        C-z suspend-client
bind-key      Space next-layout
bind-key          ! break-pane
bind-key          " split-window
bind-key          # list-buffers
bind-key          $ command-prompt -I #S "rename-session '%%'"
bind-key          % split-window -h
bind-key          & confirm-before -p "kill-window #W? (y/n)" kill-window
bind-key          ' command-prompt -p index "select-window -t ':%%'"
bind-key          ( switch-client -p
bind-key          ) switch-client -n
bind-key          , command-prompt -I #W "rename-window '%%'"
bind-key          - delete-buffer
bind-key          . command-prompt "move-window -t '%%'"
bind-key          0 select-window -t :0
bind-key          1 select-window -t :1
bind-key          2 select-window -t :2
bind-key          3 select-window -t :3
bind-key          4 select-window -t :4
bind-key          5 select-window -t :5
bind-key          6 select-window -t :6
bind-key          7 select-window -t :7
bind-key          8 select-window -t :8
bind-key          9 select-window -t :9
bind-key          : command-prompt
bind-key          ; last-pane
bind-key          = choose-buffer
bind-key          ? list-keys
bind-key          D choose-client
bind-key          L switch-client -l
bind-key          [ copy-mode
bind-key          ] paste-buffer
bind-key          c new-window
bind-key          d detach-client
bind-key          f command-prompt "find-window '%%'"
bind-key          i display-message
bind-key          l last-window
bind-key          n next-window
bind-key          o select-pane -t :.+
bind-key          p previous-window
bind-key          q display-panes
bind-key          r refresh-client
bind-key          s choose-tree
bind-key          t clock-mode
bind-key          w choose-window
bind-key          x confirm-before -p "kill-pane #P? (y/n)" kill-pane
bind-key          z resize-pane -Z
bind-key          { swap-pane -U
bind-key          } swap-pane -D
bind-key          ~ show-messages
bind-key      PPage copy-mode -u
bind-key -r      Up select-pane -U
bind-key -r    Down select-pane -D
bind-key -r    Left select-pane -L
bind-key -r   Right select-pane -R
bind-key        M-1 select-layout even-horizontal
bind-key        M-2 select-layout even-vertical
bind-key        M-3 select-layout main-horizontal
bind-key        M-4 select-layout main-vertical
bind-key        M-5 select-layout tiled
bind-key        M-n next-window -a
bind-key        M-o rotate-window -D
bind-key        M-p previous-window -a
bind-key -r    M-Up resize-pane -U 5
bind-key -r  M-Down resize-pane -D 5
bind-key -r  M-Left resize-pane -L 5
bind-key -r M-Right resize-pane -R 5
bind-key -r    C-Up resize-pane -U
bind-key -r  C-Down resize-pane -D
bind-key -r  C-Left resize-pane -L
bind-key -r C-Right resize-pane -R

Copy mode

Resoure