tmux

tmux使用記錄


更新記錄

item note
20160815 第一版
20161214 新增tmux範例

目錄


TMUX

tmux is a terminal multiplexer

tmux manual

  • tmux manual
    • 由於prefix key被我改成C-x
    • (C-x) + c
      開新的視窗
    • (C-x) + ?
      List all key bindings.

The default command key bindings are:

key binding note
其它功能
, Rename the current window
c Create a new windows
切換功能
0 to 9 Select windows 0 to 9
n Change to the next window
p Change to the previous window
復製功能
[ Enter copy mode to copy text or view the history
] Paste the most recently copied buffer of text
分割畫面功能
% Split the current pane into two, letft and right
Split the current pane into two, top and bottom
Up, Down,Left, Right Change to the pane above, below, to the left, or to the right of the current pane.
Space Arrange the current window in the next preset layout.
x Kill the current pane.

tmux範例

  • tmux ls
    顯示目前有多少tmux終端,每個終端往了多少分頁

    1
    2
    3
    $ tmux ls
    0: 7 windows (created Mon Dec 12 13:34:06 2016) [185x54] (attached)
    1: 4 windows (created Tue Dec 13 10:28:41 2016) [159x25] (attached)
  • 開啟已存在的tmux

    1
    tmux attach -t 0

~/.tmux.conf

  • 使用ctl+x取代原本的功能key(ctl+b)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    set -g prefix C-x
    unbind C-b

    # vi
    setw -g mode-keys vi

    # mouse scroll
    set -g mode-mouse on

    # 256 colors please
    set -g default-terminal "screen-256color"

    # Bad Wolf
    set -g status-fg white
    set -g status-bg colour234
    set -g window-status-activity-attr bold
    set -g pane-border-fg colour245
    set -g pane-active-border-fg colour39
    set -g message-fg colour16
    set -g message-bg colour221
    set -g message-attr bold

    # Custom status bar
    # Powerline symbols:
    set -g status-left-length 32
    set -g status-right-length 150
    set -g status-interval 5

    # Inconsolata-dz-Powerline Theme:
    set -g status-left '#[fg=colour235,bg=colour252,bold] #S #[fg=colour252,bg=colour238,nobold]#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg=colour234,nobold]'
    set -g status-right '#[fg=colour238,bg=colour234,nobold]#[fg=colour245,bg=colour238] #h #[fg=colour252]#[fg=colour235,bg=colour252,bold] #(wemux status_users) '
    set -g window-status-format "#[fg=white,bg=colour234] #I #W "
    setw -g window-status-current-format " #I$ #W "
    setw -g window-status-current-bg yellow
    setw -g window-status-current-fg blue
    setw -g window-status-current-attr default
    #set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=colour25,bg=colour39,noreverse,bold] #I #W #[fg=colour39,bg=colour234,nobold]"

    #setw -g monitor-activity on
    #set -g visual-activity on

參考來源