Last active
August 25, 2025 22:24
-
-
Save samoshkin/05e65f7f1c9b55d3fc7690b59d678734 to your computer and use it in GitHub Desktop.
tmux.conf excerpt to toggle on/off session keybindings and prefix handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bind -T root F12 \ | |
| set prefix None \;\ | |
| set key-table off \;\ | |
| set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\ | |
| set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\ | |
| set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\ | |
| if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ | |
| refresh-client -S \;\ | |
| bind -T off F12 \ | |
| set -u prefix \;\ | |
| set -u key-table \;\ | |
| set -u status-style \;\ | |
| set -u window-status-current-style \;\ | |
| set -u window-status-current-format \;\ | |
| refresh-client -S | |
| wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]" | |
| set -g status-right "$wg_is_keys_off #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host" |
To send the get-out key (Ctrl+) to child T-Mux, just repeat it, and so on. So once the child T-Mux also enter the on key-table, now you have to press Ctrl+\ 4x to send it to the grand-child T-Mux.
This tricky requirement of exponentially-growing key presses to interact with nested tmux instances is solved in the tmux-matryoshka plugin (previously tmux-nested)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It may be arbitrary, but it's not unlimited and we have to remember various keys.
Here is the true unlimited nested T-Mux:
I used
onkey-table, but it's actuallypre-on, but it's just too long.To send the
get-outkey (Ctrl+) to child T-Mux, just repeat it, and so on. So once the child T-Mux also enter theonkey-table, now you have to pressCtrl+\4x to send it to the grand-child T-Mux. It can be laborious, however it can be unlimited and the status indicator hopefully help us point out which T-Mux sessions are in theonkey-table.The only caveats if you actually have local T-Mux of the same users nested (by hacking it via
TMUX= tmux) as in this case you will create a new session of T-Mux (connected to the same server). In this case, theset-option key-table ...from any T-Mux sessions connected to the same server will affect their siblings in such whoever in theprefixmode will reset back toroot. This may be T-Mux bug or unintended consequences as the command should only effect the "current" session, i.e. no-goption is given.If different users start the T-Mux, then it's fine as each user will have their own T-Mux server. If you must do locally nested T-Mux with the same user, then you need to force it to start a different server, via
-Lor-Soption.