zellij: Unable to send ctrl-g without rebinding in the config (one liner)
Description
With the default config I can’t seem to find a way to send Ctrl-g to any programs I run in zellij because it’s the key to both enter and exist the locked mode.
You can send any other key that’s already used by the default config by entering the locked mode with Ctrl-g, then hitting the key you want to send, and leaving locked mode with Ctrl-g again, but that doesn’t work for Ctrl-g itself.
Information
- zellij 0.6.0
- Arch Linux 5.11.16-zen1-1-zen
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 27 (11 by maintainers)
I noticed that I’m unable to send
Ctrl-gwhen I tried to use it in vim to print the current file name.Some solution that come to mind are these:
Change the keybind to leave locked mode to
esc. You can already sendescin normal mode, though you might want to sendescin locked mode without wanting to leave locked mode.If
Ctrl-gis the first key entered in locked mode: sendCtrl-gand leave locked mode. This behavior is similar toCtrl-b Ctrl-bwith the default tmux config, but this prevents users from leaving locked mode without sending anything if they entered it by accident.Add a keybind that sends only the next character, like
Ctrl-vin vim’s insert mode.This is my favorite solution. I would also:
Ctrl-gand change the current behaviour to happen withCtrl-G(uppercaseG). This way we can make just a minor change to the interface by changing it to<g/G> LOCK-- INTERFACE LOCKED --indication for the lowercase variant (the temporary one) to-- INTERFACE TEMPORARILY LOCKED --to make it clear to the user.What do you think?
Friends, I want to stress again: we can bind/unbind/rebind any key in the config by changing one line. I changed the issue title accordingly to try and make it as clear as possible. I don’t know how to make this clearer. 😃 More info here: https://zellij.dev/documentation/keybindings.html
While I can empathize with wanting things to work just the way you like them out of the box - and I do agree we can do more in that area and indeed plan to - it takes less effort to adjust this in the config than it took me to write this comment.
Completely agree. Many apps use control-g. In emacs it is even the most important shortcut since this might be the only key that saves you from an emacs hang up.
This would improve on a feature that tmux has that Zellij doesn’t, the ability to pass through the prefix key.
Which in this case is an improvement over Tmux’s solution of a separate keybind just to pass through the prefix keybind.
So I believe the solution is simpler than it seems at first, at least when using the newer “non-colliding” preset.
You just have to tweak the existing binding that maps
Ctrl gto go back into locked mode to make it sendCtrl gbefore changing back to locked. ForCtrl gyou just have to addWrite 7;in front of the existing binding behavior. It almost feels too easy…Here’s the block where I made the change in the default “non-colliding” config file on a fresh install:
This appears to work just like the usual approach in tmux where you type the prefix twice to send the prefix to the application. Between the non-colliding preset and this easy hack I finally feel like I can move on from tmux.
@imsnif I very nearly put off switching from tmux again over this, because at first glance for a beginner it looks like there is no real support for this behavior, even after doing a decent amount of searching (and I also tried asking a few LLMs). In this thread it really looks like you are saying to just rebind the prefix key, but people are asking how to send that prefix key to the underlying pane in the rare situations where they may need to do so.
This simple config tweak might be worth putting in the docs so people can easily see how to send their chosen prefix. For me in vim I do occasionally use
Ctrl gto see a file’s path when its window is too narrow to fit in the mode line.FWIW I think this bug should be re-opened and something like https://github.com/zellij-org/zellij/issues/418#issuecomment-830019834 implemented. It was rather confusing coming across this as a new user and other multiplexers having some solution to this.
Here is my hacking to send a real
Alt-gto the terminal (I usealt-ginstead ofctrl-gfor the lock mode switching key):So with this setting, in any mode (like Pane, Resize, Scroll, or whatever mode), press
Alt-gto send a realAlt-gto the terminal, and in normla mode, pressAlt-gto enter the lock mode.That is definitely an improvement over it having to be ctrl+g. However, whichever key you choose, you won’t be able to send that one to internal programs.
I think this is a very old issue and can be closed.
@vyalovvldmr - you’ll need to explicitly unbind “Ctrl g” in all modes (and hopefully bind it to something else). You can look into overriding keys here if you like: https://zellij.dev/documentation/keybindings-binding.html#overriding-keys
I just came accross the same issue: “Ctrl-g” is used to open the help screen in the nano editor. Instead of a help screen you get a lock in the terminal. “Ctrl-r” is also a nano command.
We’re definitely not alone in having this problem, and there are a number of different approaches:
The screen one will mean that my default screen bindings require me to
Ctrl+g g gin order to sendCtrl+gto the shell if I run zellij under screen for persistence 😄I also think that this is the best solution.