zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Feature Request: option to replace Ctrl modifier completely with a combination of modifiers

Open klhrt opened this issue 1 year ago • 19 comments

If there were an option to replace the Ctrl modifier with Ctrl+Super or Ctrl+Shift+Super (or any custom combo of modifier keys) I think it would instantly resolve the keybind conflict issue.

Since there's no good workaround I'm not using zellij currently; Ctrl-s, Ctrl-t, etc. are far too important in my vim setup and I would genuinely bet that a significant majority of would-be users will have deal-breaker control conflicts as well. Rebinding the individual keys that conflict is clunky, makes the mode switcher UI unhelpful, and is a lot of active effort (checking internal conflicts within zellij as well as conflicts with any programs you use regularly), whereas replacing the modifiers via a single line in the config fixes every problem at once.

e.g. alias "Ctrl" "Ctrl Shift Super"

not sure if alias would be the best config keyword, but i think it makes sense for demonstration purposes

klhrt avatar Feb 26 '23 03:02 klhrt

I agree with that, I was super excited to have a new and powerful tool to replace tmux but I endup having so much keybinding issue with yabai and nvim that I uninstall...

Being able to define a different prefix key would be perfect.

Freyskeyd avatar Mar 08 '23 08:03 Freyskeyd

prefix key is pretty handy for users switching from tmux!

EthanWng97 avatar Mar 09 '23 05:03 EthanWng97

Did you try the alt-centered-config.kdl already? I'm using it and am quite happy with it as long as there is no prefix key implemented ...

wimstefan avatar Mar 13 '23 14:03 wimstefan

For me the issue is that I use alt for almost every Yabai command :/

Freyskeyd avatar Mar 13 '23 17:03 Freyskeyd

Same story here, I am trying to adopt zellij but I keep running into conflicts with Helix. If I could use all modifiers for the leader key then it would solve the problem entirely.

As for simplifying the keybindings, having an alias / variable on the leader / prefix key would help a lot so that the leader_key is set to Ctrl by default and all the keybinding use that alias / variable. Then it becomes trivial to change the keybinding by simply changing the leader_key variable.

Ideally we should be able to set that leader / prefix to any combination of modifiers (Ctrl, Alt,Shift,Cmd)

tlvenn avatar Mar 14 '23 03:03 tlvenn

Same here. I would love zellij to have a single leader key, just like tmux and screen have. Current keybind causes way too many conflicts. I wouldn’t mind having to set-up some setting in my config file (keybinds="use-single-leader"?), but I would prefer to avoid using a completely custom set of keybindings otherwise I would not be able to use zellij on any computer that I didn’t set-up beforehand.

robinmoussu avatar Mar 15 '23 10:03 robinmoussu

And btw, the reason I’m testing zellij instead of sticking with tmux/screen (which have, imho, much less intrusive shortcuts) is because the version of tmux/screen on the servers I’m using is way too old, and rebuilding from source with cargo install is so much nicer than building anything in C/C++.

robinmoussu avatar Mar 15 '23 12:03 robinmoussu

I'm struggling with a similar problem now - trying to migrate over from tmux but I'm so used to having mapped Command+1, Command+2 to switch between windows (tabs I guess in zellij). I was trying to find a way to do this as currently I'm struggling having to ctrl-t 1, ctrl-t 2, every time. I flip between tabs constantly and aggressively so an extra step hurts. Just chiming in to add another voice that this would be huge from a user perspective.

apenney avatar Mar 16 '23 17:03 apenney

I really want to leave tmux and come over to zellij but I am a full-time neovim user and when I tried it the first time I saw that my keybindings are not working correctly because Ctrl being the Mod or Prefix key in zellij. We can set the Mod or Prefix to some other key that we prefer.

lalitmeeq avatar Apr 07 '23 18:04 lalitmeeq

Adding a request for at least the ability to use compound modifiers and add Shift and Super/Win to the allowed modifiers. Also really need to allow arrow* (L/R/U/D) with all modifiers. Ctrl+Arrow* probably doesn't make sense for most, but with compound Ctrl+Shift+Arrow* modifiers it could.

Between the window manager, the terminal, the shell, the editor/apps/tools, etc, etc, there are already quite a few key binding collisions to work out. If I can bind Crtl+Shift+(), Ctrl+Alt+(), Alt+Shift+(), Super+Ctrl+(), etc it would go a long way to clearing the key binding logjam.

kevinclevenger avatar May 24 '23 02:05 kevinclevenger

Adding a request for at least the ability to use compound modifiers and add Shift and Super/Win to the allowed modifiers. Also really need to allow arrow* (L/R/U/D) with all modifiers. Ctrl+Arrow* probably doesn't make sense for most, but with compound Ctrl+Shift+Arrow* modifiers it could.

Between the window manager, the terminal, the shell, the editor/apps/tools, etc, etc, there are already quite a few key binding collisions to work out. If I can bind Crtl+Shift+(), Ctrl+Alt+(), Alt+Shift+(), Super+Ctrl+(), etc it would go a long way to clearing the key binding logjam.

Super/Win/Cmd is not supported by most terminals, so there is nothing Zellij can do about it. Same for Ctrl+Shift. Whenever you do Shift+<char>, the terminal sends A instead of a, not Shift+a. But most terminals don't support Ctrl+Shift & they always send Ctrl+a because that is how terminals work. You can use Alt+Shift by using Alt R instead of Alt r. Zellij could add support for Ctrl+Shift+<arrow> because terminals send 2 different keys for Ctrl+<arrow> & Ctrl+Shift+<arrow>.

The best way to find out which keys are supported is to use showkey -a. If you see two different inputs from two different key combinations, then they should be usable with Zellij or support could be added for it.

One workaround for this is to overwrite keys at a terminal level i.e. to forward modifiers to some ctrl/alt combination:

With alacritty, I use the following to have a working Cmd+t/n, which is forwarded to Alt+T/N:

{
  "key_bindings":
    [
      { "chars": "\x1bT", "key": "T", "mods": "Command" },
      { "chars": "\x1bN", "key": "N", "mods": "Command" },
    ]
}

Then I was able to use the following in my Zellij config:

        bind "Alt T" { NewPane; }
        bind "Alt N" { NewTab; }

Similarly, terminals don't support Ctrl+<num>, so I've added the following:

      { "chars": "\x1b!", "key": "Key1", "mods": "Control" },
      { "chars": "\x1b@", "key": "Key2", "mods": "Control" },
      { "chars": "\x1b#", "key": "Key3", "mods": "Control" },
      { "chars": "\x1b$", "key": "Key4", "mods": "Control" },
      { "chars": "\x1b%", "key": "Key5", "mods": "Control" },
      { "chars": "\x1b^", "key": "Key6", "mods": "Control" },
      { "chars": "\x1b&", "key": "Key7", "mods": "Control" },
      { "chars": "\x1b*", "key": "Key8", "mods": "Control" },
      { "chars": "\x1b(", "key": "Key9", "mods": "Control" },
      { "chars": "\x1b)", "key": "Key0", "mods": "Control" },

Then I was able to use Ctrl+<num> as <M-!> inside (Neo)Vim.

Here \x1b is the ANSI Escape Sequence for <ESC> which represents the Alt key in terminals.

utkarshgupta137 avatar May 24 '23 08:05 utkarshgupta137

More info here & here. First one is NeoVim focused, but the principal is the same.

utkarshgupta137 avatar May 24 '23 09:05 utkarshgupta137

Kitty Keyboard Protocol lets terminals use shift. Other than kitty it seems that WezTerm and few text editors support it

https://sw.kovidgoyal.net/kitty/keyboard-protocol/

zofiasu avatar May 24 '23 10:05 zofiasu

Super/Win/Cmd is not supported by most terminals

While that may be true for a legacy/X terminals, that's not quite correct for some of the more popular modern/Wayland terminals is use.

@zofiasu is correct, for example:

wezterm https://wezfurlong.org/wezterm/config/default-keys.html CTRL+SHIFT c CopyTo="Clipboard" SUPER n SpawnWindow

kitty https://sw.kovidgoyal.net/kitty/conf/#keyboard-shortcuts kitty has created a new keyboard protocol crtl+space noted under "Legacy text keys" for NULL byte (0x0) Also mention super, cmd, command, ⌘.

alacritty

# - `mods`: Key modifiers to filter binding actions
#    - Command - Control - Option - Super - Shift - Alt
#    Multiple `mods` can be combined using `|` like this:
#       `mods: Control|Shift`.

There are many other examples in the respective documents.

@utkarshgupta137 great ideas, very helpful towards an interim solution, thank you

So I guess that the point is that more modern terminals do allow mapping things like Ctrl+Shift, Super, etc. The ask is to simply add support for them in the Zellij config options. Should the end user be using a terminal that can using those mapping then then they can take advantage of them, if not then the default Ctrl/Alt only is still there.

kevinclevenger avatar May 25 '23 04:05 kevinclevenger

Yeah, as I said in my comment, some terminals support it. There are 2 ways for terminals to support it: using CSI u & Kitty protocol. The keybindings that I mentioned were emulating the CSI u input scheme. I guess Zellij could add support CSI u and eventually the Kitty protocol. Alacritty supports neither as of now, but I'll try to remedy that. What you're seeing in Alacritty docs is the ability to use the keys for keybindings with alacritty. But they won't work as regular keys in applications that support either protocol.

utkarshgupta137 avatar May 25 '23 05:05 utkarshgupta137

No updates on this yet? I decided to use Alt to replace Ctrl. I use it a lot in my Neovim :( This should be implemented soon

chandragie avatar Jan 16 '24 10:01 chandragie

Alacritty has implemented the Kitty protocol as of 0.13.0, can confirm it's working as expected in neovim. Would be great if Zellij had support for it.

taylorthurlow avatar Jan 18 '24 07:01 taylorthurlow

also joining here the request for supporting more advanced keyboard shortcuts, ideally I'd like to be able to use cmd+character for zellij actions; it seems that the kitty protocol shows up on most searches I've done for trying to make this work somehow

aexvir avatar Feb 06 '24 23:02 aexvir

Hi, now that Alacritty has adopted the Kitty keyboard protocol we're going to adopt it too (I see this as indication that the protocol has gained wide enough adoption). I hope to get to it next month.

imsnif avatar Feb 07 '24 07:02 imsnif