목차

, , , ,

tmux configuration

tmux config file의 위치, option scope, key binding, format과 안전한 reload 방법.

Summary

File Locations

정확한 검색 순서와 system config path는 설치된 version의 man 1 tmux를 확인한다. 이미 실행 중인 server는 새 client를 열기만 해서는 config를 자동으로 다시 읽지 않는다.

Syntax

# comment
set-option -g mouse on
set-window-option -g mode-keys vi
bind-key r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded"

Options

Scope

# 현재 server option
tmux show-options -s
 
# global session option
tmux show-options -g
 
# global window option
tmux show-window-options -g

Practical Defaults

# mouse로 pane 선택, resize, copy mode 사용
set-option -g mouse on
 
# scrollback line 수
set-option -g history-limit 50000
 
# window와 pane index를 1부터 시작
set-option -g base-index 1
set-window-option -g pane-base-index 1
 
# vi-style copy mode
set-window-option -g mode-keys vi
 
# terminal capability는 실제 terminal과 tmux version에 맞춰 조정
set-option -g default-terminal "tmux-256color"
default-terminal을 무조건 바꾸면 terminfo가 없는 remote host나 오래된 system에서 application 표시가 깨질 수 있다. 먼저 infocmp tmux-256color로 entry가 있는지 확인한다.

Key Bindings

# prefix table: prefix 다음 r
bind-key r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded"
 
# prefix 없이 Alt+h/j/k/l로 pane 이동
bind-key -n M-h select-pane -L
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-l select-pane -R

Formats

tmux format은 #{name} 문법으로 session, window, pane 상태를 command output과 status line에 삽입한다.

set-option -g status-left '#S '
set-option -g status-right '#{?client_prefix,PREFIX ,}%Y-%m-%d %H:%M'
tmux display-message -p '#{session_name}:#{window_index}.#{pane_index}'
tmux list-panes -a -F '#{pane_id} #{pane_current_command} #{pane_current_path}'

Reload and Validation

# 현재 server에 적용
tmux source-file ~/.tmux.conf
 
# 별도 socket 이름으로 isolated server에서 config 확인
tmux -L config-test -f ~/.tmux.conf new-session -d -s config-test
tmux -L config-test list-sessions
tmux -L config-test kill-server
별도 socket을 사용하면 현재 작업 중인 기본 tmux server에 영향을 주지 않고 config를 확인할 수 있다. 검증용 server만 대상으로 kill-server를 실행한다.

Troubleshooting

See Also

History