Tmux: swap current pane with a hidden one
I’ve been lagging behind on Antirez’s C course (highly recommended!) and the Christmas break is the perfect time to catch up.
My current layout on my 14-inch screen: YouTube video on the left half, terminal on the right. Inside the terminal: neovim on top for coding, and a smaller pane at the bottom for either compiling/running C scripts or asking Claude for clarifications. It works, but constantly resizing or swapping panes manually is annoying.
So I came up with a small quality-of-life binding: swap the current pane with one hidden in a separate window. Now I can toggle Claude in and out with a single keystroke, keeping my coding setup intact.
The binding
Add this to your ~/.tmux.conf:
# Swap active pane with a hidden window for quick context switching.
# Pressing Tab again swaps them back (fully reversible toggle).
bind-key Tab swap-pane -d -s :_hidden.0
The -d flag keeps focus on the current window, and :_hidden.0 targets the first pane in the _hidden window.
Then, reload the config with tmux source-file ~/.tmux.conf, and create the hidden window with tmux new-window -d -n _hidden.
Voila’, now prefix + Tab will switch between the current pane and the hidden one, and vice versa!
Check out the full commit in my dotfiles.
Happy multiplexing! ✌️