If I'm working in a widescreen monitor I like to primarily use two panes and switch between them with C-a Ca
.
If I'm working on a square monitor I'll use two windows. I'd like to be able to switch between them with C-a C-a
as well without changing my tmux.conf
.
Reload tmux, switch windows at least once and press: ctrl+B (default prefix) + l (lower-case L) works like a charm!
Tmux uses the keybinding 'Prefix' followed by 'Ctrl+o' to cycle around the panes. When you use this key-binding for the first time, it moves the pane in one position clockwise.
By default, tmux sets the prefix key as Ctrl + b.
ctrl + b + % to make a vertical split. ctrl + b + " to make a Horizontal split. ctrl + b + left arrow to move to the left pane. ctrl + b + " to make a Horizontal split.
If you always want C-a to
then you can use an if-shell
that counts the number of panes in the active window to decide between last-pane
and last-window
:
bind-key C-a if-shell 'test $(tmux list-panes | wc -l) -gt 1' 'last-pane' 'last-window'
It will still be “up to you” to rearrange your panes when switching between “wide” and “square” configurations (e.g. via break-pane
and join-pane
).
In tmux 1.8 if-shell
and run-shell
do format expansion, so you can simply the shell command a bit:
bind-key C-a if-shell 'test #{window_panes} -gt 1' 'last-pane' 'last-window'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With