tmux.confの意味

今まで、俺が考えた最強のtmux.confであったり、おすすめtmux.confを使ってきたが、なんとなくしか意味がわかっておらず、メンテナンスするには限界がきた。 そこで理解が曖昧な物に関して備忘録的にまとめる。

ただ以下のmanを読むのが好ましい。 man7.org

bindとbind-keysの違い

bind h select-pane -L

bindはbind-keysのエイリアス

setとbindは?

set -g status-fg white

setはset-optionのエイリアス -gはglobalの意味

つまりsetはオプションの変更、bindはkeyへの割当

bindの後のkey(e.g. -T)は大文字小文字を識別するか?

setwは?

set-window-optionのエイリアス

bind-keyの構文

bind-key [-nr] [-N note] [-T key-table] key command [arguments]
                   (alias: bind)
             Bind key key to command.  Keys are bound in a key table.
             By default (without -T), the key is bound in the prefix key
             table.  This table is used for keys pressed after the
             prefix key (for example, by default ‘c’ is bound to
             new-window in the prefix table, so ‘C-b c’ creates a new
             window).  The root table is used for keys pressed without
             the prefix key: binding ‘c’ to new-window in the root table
             (not recommended) means a plain ‘c’ will create a new
             window.  -n is an alias for -T root.  Keys may also be
             bound in custom key tables and the switch-client -T command
             used to switch to them from a key binding.  The -r flag
             indicates this key may repeat, see the repeat-time option.
             -N attaches a note to the key (shown with list-keys -N).

             To view the default bindings and possible commands, see the
             list-keys command.

keyをコマンドにバインドします。 keyはkey tableにバインドされます。 デフォルトでは (-T を指定しない場合)、キーはprefix key tableにバインドされます。このtableは、prefix keyの後に押されたkeyに使用されます (例えば、デフォルトでは 'c' はprefix tableの new-window にバインドされているので、'C-b c' はnew-windowを生成します)。 root tableは、prefix keyなしで押されたkeyに使用されます。 root talbeの new-window に 'c' をバインドすると (推奨されません)、単純な 'c' で新しいウィンドウが作成されます。 -n は -T root のエイリアスです。 keyはcustom key tableにバインドすることもでき、switch-client -Tコマンドを使ってキーバインドからcustom key tablesに切り替えることができます。 - r フラグは、このキーが繰り返し使用できることを示します。 -N は、キーにメモを付けます (list-keys -N で表示されます)。

既定のバインディングと可能なコマンドを表示するには、 list-keys コマンドを参照してください。

bind -T copy-mode-vi v send -X begin-selection

bind-keyを行う

-T copy-mode-viとあるため、copy-mode-viという名前が付いているtableにバインドする

keyはv

commandはsend -X begin-selection.

つまり、prefixの後にvが押された場合に、send -X begin-selectionを行う。このbind設定はvi-copy-modeと行ったkey tableに保存する。