Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggle on/off all keybindings #237

Closed
acornejo opened this issue Dec 11, 2015 · 11 comments
Closed

toggle on/off all keybindings #237

acornejo opened this issue Dec 11, 2015 · 11 comments

Comments

@acornejo
Copy link

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
Copy link
Member

nicm commented Dec 11, 2015

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.

@acornejo
Copy link
Author

@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
Copy link
Member

nicm commented Dec 11, 2015

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.

@acornejo
Copy link
Author

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
Copy link
Member

nicm commented Dec 11, 2015

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
Copy link
Member

nicm commented Dec 12, 2015

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
Copy link
Member

nicm commented Dec 12, 2015

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

@nicm
Copy link
Member

nicm commented Dec 12, 2015

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
Copy link
Member

nicm commented Dec 12, 2015

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
Copy link
Member

nicm commented Dec 12, 2015

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

@nicm nicm closed this as completed Dec 13, 2015
@lock
Copy link

lock bot commented Feb 16, 2020

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.

@lock lock bot locked and limited conversation to collaborators Feb 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants