tmux で main-vertical / main-horizontal で layout を変更と同時にカレント(アクティブ)のペインを main のペインにしたい
これはターミナルマルチプレクサ Advent Calendar の4日目です。
ターミナルマルチプレクサ Advent Calendar 2011 : ATND
今日は tmux の小ネタです。
したいこと
- tmux で main-vertical / main-horizontal で layout を変更と同時にカレント(アクティブ)のペインを main のペインにしたい*1
例えば以下のような layout の pane2 で作業をしている時に、
横方向で広いレイアウトで作業をしたくなったと仮定します。
通常であれば、
:select-layout main-horizontal
とした後に、:swap-pane や :select-pane を使いながら任意の場所に移動すると思います。
ですが、これを行うのは、脳に負担がかかり健康によくありません。
解決策
bind -r H select-layout main-vertical \; swap-pane -s : -t 0 \; select-pane -t 0 \; resize-pane -R 9 bind -r K select-layout main-horizontal \; swap-pane -s : -t 0 \; select-pane -t 0 \; resize-pane -D 18
これを ~/.tmux.conf に書きます。 *2
この動作自体は tmux では設定ができないため、マルチコマンドを利用します。
tmux ではマルチコマンドがセミコロンでつなげることで、設定できます。
Multiple commands may be specified together as part of a command sequence. Each command should be separated by spaces and a semicolon; commands are executed
sequentially from left to right. A literal semicolon may be included by escaping it with a backslash (for example, when specifying a command sequence to
bind-key).
keybind + H keybind + K
これで main-vertical / main-horizontal で layout を変更と同時にカレント(アクティブ)のペインを main のペインにすることが可能となりました。*3
もしもっといい方法や他の方法がある方は教えて頂けると嬉しいです。