tmux/tmux

toggle on/off all keybindings

acornejo opened this issue · 11 comments

A feature which I miss in tmux, is the ability to turn on or off all the keybindings at once.

Byobu (tmux wrapper) provides this feature with the Shift-F12 keybinding (see here https://help.ubuntu.com/community/Byobu)

I prefer to use tmux on its own rather than Byobu, hence this feature request.

This is VERY useful when you ssh into remote machines and open tmux there. That way, you can simply press toggle the keybindings off, then work inside the tmux in the ssh session, and then turn the key bindings on to work on the "outer" tmux. This is much more convenient than Ctrl-b b or Ctrl-b Ctrl-b, especially since it works out of the box with any custom user key bindings.

nicm commented

Set the prefix to some key that doesn't exist and change it back when you're done.

On 11 Dec 2015 20:48, Alex Cornejo notifications@github.com wrote:A feature which I miss in tmux, is the ability to turn on or off all the keybindings at once.

Byobu (tmux wrapper) provides this feature with the Shift-F12 keybinding (see here https://help.ubuntu.com/community/Byobu)

I prefer to use tmux on its own rather than Byobu, hence this feature request.

This is VERY useful when you ssh into remote machines and open tmux there. That way, you can simply press toggle the keybindings off, then work inside the tmux in the ssh session, and then turn the key bindings on to work on the "outer" tmux. This is much more convenient than Ctrl-b b or Ctrl-b Ctrl-b, especially since it works out of the box with any custom user key bindings.

—Reply to this email directly or view it on GitHub.

@nicm unfortunately that is only a good solution when your bindings had a prefix already.

For frequently used bindings, folks often use a single chord. Example, Ctrl-{h,k,k,l} is a frequently used binding to switch between panes. If I have to press the prefix before then it essentially removes the convenience of having a prefix-less biding for that action on the first place.

nicm commented

Right but you could just unbind them and then put them back. I don't think an option to do this is necessary.
But an option to set the default key would allow this and also be useful for some other things (per session key bindings). So that would be a better thing to add.
On 11 Dec 2015 22:17, Alex Cornejo notifications@github.com wrote:@nicm unfortunately that is only a good solution when your bindings had a prefix already.

For frequently used bindings, folks often use a single chord. Example, Ctrl-{h,k,k,l} is a frequently used binding to switch between panes. If I have to press the prefix before then it essentially removes the convenience of having a prefix-less biding for that action on the first place.

—Reply to this email directly or view it on GitHub.

Not sure what you mean by "set the default key", but per session key bindings would definitely solve this issue (and be super useful). I only requested the toggle because that seemed like an easier feature to implement, but I agree that per session bindings would be immensely more powerful.

nicm commented

A per session option to set the default key table (the one that is returned to after a command is run etc), at the moment it is always called "root". If it was configurable you could set it to different tables for different sessions and set it to an empty table to turn off all key bindings.
On 11 Dec 2015 23:04, Alex Cornejo notifications@github.com wrote:Not sure what you mean by "set the default key", but per session key bindings would definitely solve this issue (and be super useful). I only requested the toggle because that seemed like an easier feature to implement, but I agree that per session bindings would be immensely more powerful.

—Reply to this email directly or view it on GitHub.

nicm commented

Try http://pastebin.ca/raw/3282694

But because of the way the prefix option works you will unfortunately still need to disable it (it is still a special case and always jumps straight to the prefix table).

You can either set it to something rare globally and bind your real prefix: "bind -n C-b switch -Tprefix".

Or just do it for the duration of you toggle command, something like:

bind -Troot C-x if -F '#{s/empty//:key-table}' 'set prefix C-F12; set key-table empty' 'set -u prefix; set -u key-table'
bind -Tempty C-x if -F '#{s/empty//:key-table}' 'set prefix C-F12; set key-table empty' 'set -u prefix; set -u key-table'

nicm commented

This is slightly updated version: http://pastebin.ca/raw/3282712

nicm commented

I think I will take a look at how we could avoid making the prefix key special, or at least allow it to be disabled more nicely.

nicm commented

Ok I have just committed code so you can set prefix to None, so instead of swapping it too you can do (with this diff), something like:

set -g prefix None
bind -Troot C-b switchc -Tprefix
bind -Tprefix C-x if -F '#{s/empty//:key-table}' 'set key-table empty' 'set -u key-table'
bind -Tempty F12 switchc -Tprefix

To make C-b the prefix, C-b C-x switch key bindings off, then F12 C-x switch them on again.

nicm commented

I applied the diff above as well, so it should all be there next time GitHub syncs up.

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.