zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
22.1k stars 673 forks source link

Unable to send ctrl-g without rebinding in the config (one liner) #418

Closed muffin4 closed 1 year ago

muffin4 commented 3 years ago

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

imsnif commented 3 years ago

True. This is indeed an issue. I think it's one of the reasons Ctrl-g was chosen, since there aren't that many uses for it. Out of curiosity: is there a specific use this is blocking for you?

Also: do you have a suggestion on a UX for this?

muffin4 commented 3 years ago

I noticed that I'm unable to send Ctrl-g when I tried to use it in vim to print the current file name.

Some solution that come to mind are these:

imsnif commented 3 years ago
* Add a keybind that sends only the next character, like `Ctrl-v` in vim's insert mode.

This is my favorite solution. I would also:

  1. Make this keybind Ctrl-g and change the current behaviour to happen with Ctrl-G (uppercase G). This way we can make just a minor change to the interface by changing it to <g/G> LOCK
  2. Change the -- 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?

a-kenji commented 3 years ago

I also think that this is the best solution.

imsnif commented 3 years ago

(I'm unsure if terminals are able to detect ctrl-shift-g, btw - if that doesn't work we might have to change it to a different char)

SaintFenix commented 3 years ago

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.

TheLostLambda commented 3 years ago

(I'm unsure if terminals are able to detect ctrl-shift-g, btw - if that doesn't work we might have to change it to a different char)

This should work, it should come through as Ctrl('G') in our Key struct :)

dantepippi commented 3 years ago

From some initial tests using Ctrl + key or Ctrl +shift + key both have the same behavior. i.e both Ctrl+r and Ctrl+Shift+r will switch to the Resize mode.

khs26 commented 3 years ago

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 g in order to send Ctrl+g to the shell if I run zellij under screen for persistence :D

fansari commented 3 years ago

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.

imsnif commented 3 years ago

I think @dantepippi is working on a fix for this, right? Meanwhile, a workaround here can be to change the keybindings: https://zellij.dev/documentation/keybindings.html

fansari commented 3 years ago

An idea would be to use some Ctrl which you normally don't need for other stuff like Emacs or nano. In screen I used to use "Ctrl-J" (instead of "Ctrl-A" which is needed for Emacs). Using this as first control sequence and then a second letter for zellij (e.g. Ctrl-j + q instead of just Ctrl-q for terminating) could be a good option. But this is just my opinion.

fansari commented 3 years ago

Here a workaround for nano:

vyalovvldmr commented 1 year ago

Any workaround for vim with Ctrl-g combination? I tried something like this but it doesn't help. Seems like zellij still prevents passing through Ctrl-g combination to vim.

keybinds {
    locked {
        bind "Alt g" { SwitchToMode "Normal"; }
        bind "Ctrl g" {}  // Cancel default binding
    }
    shared_except "locked" {
        bind "Alt g" { SwitchToMode "Locked"; }
        bind "Ctrl g" {}  // Cancel default binding
    }
}

I also tried this way but in this case zellij still toggles lock mode with Ctrl-g. Even if there is no bind "Ctrl g" in a config file.

keybinds {
    locked {
        bind "Alt g" { SwitchToMode "Normal"; }
    }
    shared_except "locked" {
        bind "Alt g" { SwitchToMode "Locked"; }
    }
}
imsnif commented 1 year ago

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

igxactly commented 1 year ago

has this issue been addressed? I think this is the only thing that blocks most of user from using zellij as a main terminal multiplexer. and so do i.

as it may affect nano, emacs, any kind of CUI applications.

milanglacier commented 1 year ago

has this issue been addressed? I think this is the only thing that blocks most of user from using zellij as a main terminal multiplexer. and so do i.

as it may affect nano, emacs, any kind of CUI applications.

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.

imsnif commented 1 year ago

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.

tmccombs commented 1 year ago

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.

milanglacier commented 1 year ago

I find an interested reddit thread where the OP shares how he handled the keybinding conflict with TUI pogram like vim/emacs...

https://www.reddit.com/r/vimporn/comments/10eqj6z/comment/j4wsfbh/?utm_source=share&utm_medium=web2x&context=3

It would be useful for people who wants to try zellij but doesn't get used to its keybindings.

milanglacier commented 1 year ago

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.

Here is my hacking to send a real Alt-g to the terminal (I use alt-g instead of ctrl-g for the lock mode switching key):

    locked {
        bind "Alt g" { SwitchToMode "Normal"; }
    }

    normal {
        bind "Alt g" { SwitchToMode "Locked"; }
    }

    shared_except "locked" {
        bind "Ctrl a" { SwitchToMode "Tmux"; }
        bind "Alt p" { SwitchToMode "Pane"; }
        bind "Alt r" { SwitchToMode "Resize"; }
        bind "Alt s" { SwitchToMode "Scroll"; }
        bind "Alt o" { SwitchToMode "Session"; }
        bind "Alt t" { SwitchToMode "Tab"; }
        bind "Alt m" { SwitchToMode "Move"; }
        bind "Alt g" { Write 27 7015; SwitchToMode "Normal"; } // send a real Alt+g to the terminal
    }

So with this setting, in any mode (like Pane, Resize, Scroll, or whatever mode), press Alt-g to send a real Alt-g to the terminal, and in normla mode, press Alt-g to enter the lock mode.

valankar commented 1 year ago

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.

smangels commented 1 year ago

I could not fully understand how to encode "ctrl + 'a'" using a write action as keybinding?!? Because I realized the I was unable to send Ctrl+a, Ctrl+k, Ctrl+y and Ctrl+e to a ZSH terminal session running in a pane. Instead the "^A", "^K" is printed.