tmux config file의 위치, option scope, key binding, format과 안전한 reload 방법.
-g를 명시한다.source-file로 다시 읽되, 적용 전에 별도 server에서 syntax를 검증한다.~/.tmux.conf: 전통적인 user config$XDG_CONFIG_HOME/tmux/tmux.conf: XDG user config/etc/tmux.conf: 일반적인 system-wide config 위치이며 build 또는 platform에 따라 다를 수 있다.tmux -f PATH: 지정한 config file로 새 server를 시작한다.man 1 tmux를 확인한다. 이미 실행 중인 server는 새 client를 열기만 해서는 config를 자동으로 다시 읽지 않는다.
# 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"
#로 시작하는 줄은 comment다.$() 같은 command substitution을 직접 실행하는 script가 아니다.buffer-limit.-g를 사용한 global default에 적용한다. 예: status, mouse.mode-keys, automatic-rename.@name 형식이며 plugin이나 user config에서 자유롭게 사용한다.# 현재 server option tmux show-options -s # global session option tmux show-options -g # global window option tmux show-window-options -g
# 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가 있는지 확인한다.
# 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
bind-key는 기본적으로 prefix key table에 binding을 만든다.-n은 -T root의 shorthand이며 prefix 없이 key를 처리한다.unbind-key KEY는 binding을 제거한다.tmux list-keys -T prefix와 tmux list-keys -T root로 충돌을 확인한다.
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}'
# 현재 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
kill-server를 실행한다.
unknown option 또는 unknown command는 설치된 tmux가 config 문법보다 오래된 경우가 많다. tmux -V와 manual을 확인한다.tmux list-keys로 실제 table과 중복 binding을 확인한다.TERM, tmux의 default-terminal, host의 terminfo를 함께 확인한다.tmux -f /dev/null 또는 별도 최소 config로 원인을 격리한다.