page counter next up previous contents
Next: Fail2ban Up: SSH Server Previous: SCP RSYNC Not Work   Contents   DYWANG_HOME

TMUX 多視窗

  1. tmux 是一套 tty 下的多視窗程式,可於視窗中切出多個水平或垂直視窗,並可開啟不同的 Session,Session 下又可開啟多個分項。不同專案可用不同 Session 代表,各分項可想成專案內的不同檔案。
  2. 用法:在終端機下 tmux 指令,即開啟一個 Session,此時亦同時開啟一個分項(在下方可看到 0:bash*),表示目前所在位置為 0:bash*。
  3. 操作方式:<Ctrl+b> + 功能鍵,以下使用 <c-b> 代表 <Ctrl+b>
  4. 多個分項操作指令
    <c-b> + c       開啟另一個分項
    <c-b> + 數字     跳到那一個分項
    <c-b> + w       選擇要到哪一個分項
    <c-b> + n       跳到下一個分項
    <c-b> + p       跳到上一個分項
    <c-b> + l       會到上次的分項,2個分項互相切換
    <c-b> + ,       替此分項暫時命名,可以知道是開啟哪個檔案
    <c-b> + &       關掉目前這個分項
    <c-b> + d       將 tmux 放到背景中,回到前端終端機
    
  5. 單一分項分割視窗
    <c-b> + "       水平分割視窗
    <c-b> + %       垂直分割視窗
    <c-b> + 空白鍵   重新排列視窗
    <c-b> + 方向鍵   切換分割視窗
    <c-b> + 方向鍵   (同時)調整分割視窗大小
    <c-b> + x       關掉目前的分割視窗
    <c-b> + q       顯示第幾個分割視窗
    <c-b> + f       尋找所有分項內的分割視窗
    <c-b> + t       顯示時間(有點類似屏保作用)
    <c-b> + !       將目前的分割視窗開成單獨一個分項
    
  6. <c-b> + ? 可列出所有指令的說明:
    bind-key        C-b send-prefix                                  [33/33]
    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
    


De-Yu Wang 2020-05-19