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

Support multiple modifier keys #735

Open
qwerty01 opened this issue Sep 20, 2021 · 29 comments
Open

Support multiple modifier keys #735

qwerty01 opened this issue Sep 20, 2021 · 29 comments
Labels
action Issues related to actions help wanted Extra attention is needed

Comments

@qwerty01
Copy link

I was looking around for a way to do multiple modifier keys for an action and was unable to find any in configuration files or documentation. After doing a little digging, it looks like it's not currently supported, as keys are stored at zellij-tile::data::Key and doesn't have an option for multiple modifier keys. One solution could be to change Keys to be a struct rather than an enum and have fields for modifiers and key values.

This might cause some issues with other language keyboards if they have different modifier keys (maybe composition keys?), but for a US keyboard, I believe these are the only modifier keys:

  • Ctrl
  • Alt
  • Shift
  • Windows

For storing multiple modifiers, I believe either using the bitfield crate (https://crates.io/crates/bitfield) or a struct of bools would work.

Supporting multiple modifiers will also require changes the the configuration file format.
I'm not sure what would be the best way to represent a keybind, but something like this could work:

keybinds:
    normal:
        - action: [SwitchToMode: Locked,]
          key: [{modifiers: [Ctrl, Alt], key: 'g'},]
@a-kenji a-kenji added the action Issues related to actions label Sep 21, 2021
@imsnif
Copy link
Member

imsnif commented Sep 23, 2021

Unfortunately I'm not 100% sure this is possible within the terminal emulator landscape we're working in. It's not just a question of how we store or configure the keys, but also a question of how we serialize/deserialize them from/to stdin. This is an issue I've hit several times and have not yet had a chance to fully investigate. I think most terminal emulators won't differentiate between a ctrl-j and a ctrl-alt-j, for example. There really is a limited amount of things we can do here.

If you (or someone else) would like to investigate this more, I'd be happy to give some pointers.

@ghost
Copy link

ghost commented Sep 23, 2021

There are actually multiple solutions in terminal emulators:

  • xterm modifyOtherKeys - this is the "CSI u" type of encoding described here and is able to detect ctrl-alt-j vs ctrl-j.
  • xterm PC-Style function keys - see table on bottom for ctrl/alt/shift modifier for keys. This works for function keys, arrows, home/end/ins/del/pgup/pgdn/etc.
  • kitty has its own CSI u protocol here which some terminals are also picking up. This one can also disambiguate between key down and up.

@imsnif
Copy link
Member

imsnif commented Sep 24, 2021

Thanks @klamonte for this great information!!

Being a multiplexer, I guess we would ideally have to support all of these. I'm very open to this change, but this seems like a bit of a tall order (especially since we're using Termion to parse stdin and unless I'm mistaken I don't think they support any of these specifications). Do you have any information about which one of these is the most common?

@ghost
Copy link

ghost commented Sep 24, 2021

Start with PC-style function keys. I'm seeing support with xterm, wezterm, gnome-terminal, konsole, kitty, and alacritty at the least, which is quite a bit of coverage. It's also something that anything intending to work with TERM=xterm should support, since it is default behavior for xterm.

@imsnif imsnif added hacktoberfest For the hacktoberfest month help wanted Extra attention is needed labels Sep 25, 2021
@imsnif imsnif removed the hacktoberfest For the hacktoberfest month label Oct 1, 2022
@alanwsmith
Copy link

I've got a bunch of CTRL-ALT-whatever keys mapped on my keyboard to use with my editor. As described above they aren't working. No new info from me, just marking that there's at least two folks in the world who have the issue. Given that number, I wouldn't expect this to make it up the priority list. (Which I completely understand)

Next step for me is to move to to single modifiers. Leaving this as a note for anyone else who stumbles across it.

@raulvc
Copy link

raulvc commented Apr 4, 2023

I'm trying to adapt my terminator shortcuts (.i.e.: "ctrl + shift + o" for horizontal splitting) so that I don't have to learn a new routine, does that mean it's impossible right now? 😢

edit: ok, using alacritty I can send a command 👍
for the example above:

key_bindings:

  • { key: O, mods: Control|Shift, chars: "\x10d" }

@ethanmsl
Copy link

ethanmsl commented May 9, 2023

What's the status of this right now, if I may?

As it stands Zellij breaks a lot of my existing commands for neovim.
Simplest fix would be to map a multi-modifier so that I don't have collision with existing mod combinations.
(really liking Zellij, hoping for a workaround as this breaks my ability to use it while coding)

Edit: worth noting the workaround of cntl+g to lock a screen and block all other zellij associated hot keys (for anyone else who comes upon this)

@multivac61
Copy link

I am running into the same issue when combining neovim with zellij.

@KevinStirling
Copy link

Also running into this issue while using helix inside of zellij, as there are some shortcuts that use ctrl. The ctrl+g workaround mentioned by @ethanmsl works well enough for now, but it would be great if I could use a Meh key modifier combo in place of ctrl for zellij inputs.

Or if that isn't possible, maybe another mode that would allow us to use the alt bindings for navigation while the ctrl bindings are locked, like the way they are in the interface locked mode?

@Imberflur
Copy link
Contributor

Or if that isn't possible, maybe another mode that would allow us to use the alt bindings for navigation while the ctrl bindings are locked, like the way they are in the interface locked mode?

I'm not completely sure if this would work for you, but my current approach for this is adding these keybindings in my config:

Details
keybinds {
    // ...
    locked {
        // ...
        bind "Alt h" { MoveFocusOrTab "Left"; }
        bind "Alt l" { MoveFocusOrTab "Right"; }
        bind "Alt j" { MoveFocus "Down"; }
        bind "Alt k" { MoveFocus "Up"; }
    }
    // ...
}

@stonewell
Copy link

https://github.com/crossterm-rs/crossterm supports kitty keyboard protocol, but replace termion with crossterm maybe too much work

@utkarshgupta137
Copy link

If I'm not wrong, Zellij uses termwiz which does seem to support both CsiU & Kitty protocol: https://docs.rs/termwiz/latest/termwiz/input/enum.KeyboardEncoding.html

@oredaze
Copy link

oredaze commented Jan 6, 2024

I am a long time user of tiling window managers as well as tmux, and my muscle memory is dead set on resizing with Ctrl + Alt + {h,j,k,l}, so I trip every time I need to resize in zellij.
(as well as the lack of Alt + Tab. Alt + Enter, but that is a different topic)

I don't know what libraries and stuff zellij uses, but they can't be that limiting can they...?

@fermino
Copy link

fermino commented Jan 8, 2024

Hey :) I'm willing to put in the time to implement this, but I would need a bit of guidance to know where to look. For what I've gathered zellij uses termwiz now and it should be a matter of adding the handling of whatever escape sequences are to be supported; right?

@wd
Copy link

wd commented Jan 16, 2024

I used Emacs in the terminal, I had to use complex key bindings to avoid conflict with Emacs 😭
I use Ctl+alt+<key> in tmux now..

EDIT: thanks to @mkon , #735 (comment). Now I can use zellij without a problem.

@svyatoclav
Copy link

Same problem here: I actually can't use Zellij just because I can't bind Ctrl + Alt + h/j/k/l to move around like in Tmux... I hope this feature will be implemented very soon and I can finally ditch tmux and go full zellij! I also very often use Ctrl and Alt (also with h/j/k/l too) while in Neovim and I can't live without this keys/shortcuts/binds for sure... So I see only one way of moving around multiplexers: with both of any modifier keys.

@cranil
Copy link

cranil commented Mar 1, 2024

I use the § as a modifier on tmux it's a key I would rarely ever use in a terminal and if I have to I just tap it twice. It would be nice if something like that would be possible here.

@kkrime
Copy link

kkrime commented Mar 1, 2024

This issue needs love, this is literally the only thing stopping me from adopting zellij

@stevenxxiu
Copy link

Agreed. I use Tmux, which has a similar issue Possible regression: tmux silently swallows extended keys · Issue #2705 · tmux/tmux. This makes a lot of programs unusable. The issue seems rather stagnant.

If Zellij fixes this issue, I'd immediately switch to it. Tmux and Zellij are the only modern terminal multiplexers I know of.

@imsnif
Copy link
Member

imsnif commented Mar 1, 2024

Friends - respectfully: please do not add comments to this issue (or any other issue, really) saying that you want/need this. It doesn't help and mostly serves to demotivate me. I don't think this is the desired goal.

Thanks,
--Your overworked and frustrated maintainer

@mrghosti3
Copy link

Is there any PR or branch where work has been started? I could take a look and maybe do some testing.

If not, then maybe I could hack around and see if it is easy to add support for multiple modifier keys. Hints and tips for project testing are appreciated.

@imsnif
Copy link
Member

imsnif commented Mar 1, 2024

Hi. There is no branch, it is not easy and reviewing a PR for this will take me longer than implementing it myself. I realize you really want this, but please be patient and see my previous comment.

Thank you.

@mrghosti3
Copy link

Fair enough. Thanks for the work you're doing. Feel free to ping if you need extra test subjects ;D

@mkon
Copy link

mkon commented Mar 1, 2024

My workaround for this for anyone interested:

Essentially in your terminal, you can bind key combinations to PUS escape codes, example in alacritty:

[keyboard]
bindings = [
  { key = "Left",  mods = "Command",     chars = "\uE000" },
  { key = "Right", mods = "Command",     chars = "\uE001" },
  { key = "Up",    mods = "Command",     chars = "\uE002" },
  { key = "Down",  mods = "Command",     chars = "\uE003" },
  { key = "-",     mods = "Command",     chars = "\uE016" },
  { key = "+",     mods = "Command",     chars = "\uE017" },
  { key = "[",     mods = "Command",     chars = "\uE023" },
  { key = "]",     mods = "Command",     chars = "\uE024" },
  { key = "Enter", mods = "Command",     chars = "\uE026" },
  { key = "F",     mods = "Command",     chars = "\uE106" },
  { key = "G",     mods = "Command",     chars = "\uE107" },
  { key = "I",     mods = "Command",     chars = "\uE109" },
  { key = "P",     mods = "Command",     chars = "\uE116" },
  { key = "S",     mods = "Command",     chars = "\uE119" },
  { key = "T",     mods = "Command",     chars = "\uE120" },
  { key = "W",     mods = "Command",     chars = "\uE123" },
  { key = "M",     mods = "Command|Alt", chars = "\uE165" },
  { key = "O",     mods = "Command|Alt", chars = "\uE167" },
  { key = "P",     mods = "Command|Alt", chars = "\uE168" },
  { key = "R",     mods = "Command|Alt", chars = "\uE170" },
  { key = "S",     mods = "Command|Alt", chars = "\uE171" },
  { key = "T",     mods = "Command|Alt", chars = "\uE172" },
]

Then in zellij you can bind these key codes, replacing the defaults. Then there should be no more collisions. You just have to press this combination when editing the config and it will insert these characters, but the binding will work.

It will look something like this probably, maybe a bit different depending on the font you use:

    shared_except "locked" {
        bind "" { SwitchToMode "Locked"; }
        // bind "Ctrl q" { Quit; }
        bind "" { NewPane "Down"; } // Cmd-Enter
        bind "" { ToggleFloatingPanes; }
        bind "" { NewTab; } // Cmd-T
        bind "" { MoveFocusOrTab "Left"; }
        bind "" { MoveFocusOrTab "Right"; }
        bind "" { MoveFocus "Down"; }
        bind "" { MoveFocus "Up"; }
        bind "" { Resize "Increase"; }
        bind "" { Resize "Decrease"; }
        bind "" { PreviousSwapLayout; }
        bind "" { NextSwapLayout; }
    }

I essentially use Command+Alt+(P,T,O,...) and Command+Arrows to move. Don't even have to use Locking.

@oredaze
Copy link

oredaze commented Mar 1, 2024

I apologize on behalf of everyone, Please don't feel rushed.

If anyone is interested in a similar solution to the above for st - this is a taste of it:

	{ XK_Tab,           Mod1Mask,       "\033[23~",      0,    0}, /* Alt + Tab > F11 */
	{ XK_Return,        Mod1Mask,       "\033[24~",      0,    0}, /* Alt + CR  > F12 */

Then in zellij I have bound F11 and F12 to a couple of things.

@LuoZhongYao
Copy link

Also running into this issue while using helix inside of zellij, as there are some shortcuts that use ctrl. The ctrl+g workaround mentioned by @ethanmsl works well enough for now, but it would be great if I could use a Meh key modifier combo in place of ctrl for zellij inputs.

Or if that isn't possible, maybe another mode that would allow us to use the alt bindings for navigation while the ctrl bindings are locked, like the way they are in the interface locked mode?

My solution is to set it to Locked mode by default, then I modified the zellij code to prohibit input in Normal mode, and then configured the following key mapping:

keybinds clear-defaults=true {
    normal {
        // uncomment this and adjust key if using copy_on_select=false
        bind "p" { SwitchToMode "Pane"; }
        bind "r" { SwitchToMode "Resize"; }
        bind "s" { SwitchToMode "Scroll"; }
        bind "o" { SwitchToMode "Session"; }
        bind "t" { SwitchToMode "Tab"; }
        bind "m" { SwitchToMode "Move"; }
        bind "h" "Left" { MoveFocus "Left"; }
        bind "l" "Right" { MoveFocus "Right"; }
        bind "j" "Down" { MoveFocus "Down"; }
        bind "k" "Up" { MoveFocus "Up"; }
        bind "x" { ToggleFocusFullscreen; SwitchToMode "Locked"; }
        bind "w" { ToggleFloatingPanes; SwitchToMode "Locked"; }
        bind "Tab" { ToggleTab; }
        bind "n" { NewTab; SwitchToMode "Locked"; }
    }
    locked {
        bind "Alt c" { Copy; }
        bind "Ctrl g" { SwitchToMode "Normal"; }
    }
    resize {
        bind "h" "Left" { Resize "Increase Left"; }
        bind "j" "Down" { Resize "Increase Down"; }
        bind "k" "Up" { Resize "Increase Up"; }
        bind "l" "Right" { Resize "Increase Right"; }
        bind "H" { Resize "Decrease Left"; }
        bind "J" { Resize "Decrease Down"; }
        bind "K" { Resize "Decrease Up"; }
        bind "L" { Resize "Decrease Right"; }
        bind "=" "+" { Resize "Increase"; }
        bind "-" { Resize "Decrease"; }
    }
    pane {
        bind "h" "Left" { MoveFocus "Left"; }
        bind "l" "Right" { MoveFocus "Right"; }
        bind "j" "Down" { MoveFocus "Down"; }
        bind "k" "Up" { MoveFocus "Up"; }
        bind "p" { SwitchFocus; }
        bind "n" { NewPane; SwitchToMode "Locked"; }
        bind "d" { NewPane "Down"; SwitchToMode "Locked"; }
        bind "r" { NewPane "Right"; SwitchToMode "Locked"; }
        bind "x" { CloseFocus; SwitchToMode "Normal"; }
        bind "z" { TogglePaneFrames; SwitchToMode "Normal"; }
        bind "e" { TogglePaneEmbedOrFloating; SwitchToMode "Normal"; }
        bind "c" { SwitchToMode "RenamePane"; PaneNameInput 0;}
    }
    move {
        bind "n" "Tab" { MovePane; }
        bind "p" { MovePaneBackwards; }
        bind "h" "Left" { MovePane "Left"; }
        bind "j" "Down" { MovePane "Down"; }
        bind "k" "Up" { MovePane "Up"; }
        bind "l" "Right" { MovePane "Right"; }
    }
    tab {
        bind "h" "Left" "Up" { GoToPreviousTab; }
        bind "l" "Right" "Down" { GoToNextTab; }
        bind "n" { NewTab; SwitchToMode "Locked"; }
        bind "x" { CloseTab; SwitchToMode "Locked"; }
        bind "s" { ToggleActiveSyncTab; SwitchToMode "Locked"; }
        bind "b" { BreakPane; SwitchToMode "Locked"; }
        bind "]" { BreakPaneRight; SwitchToMode "Locked"; }
        bind "[" { BreakPaneLeft; SwitchToMode "Locked"; }
        bind "r" { SwitchToMode "RenameTab"; TabNameInput 0; }
        bind "Tab" { ToggleTab; }
    }
    scroll {
        bind "e" { EditScrollback; SwitchToMode "Locked"; }
        bind "s" { SwitchToMode "EnterSearch"; SearchInput 0; }
        bind "Ctrl c" { ScrollToBottom; SwitchToMode "Locked"; }
        bind "j" "Down" { ScrollDown; }
        bind "k" "Up" { ScrollUp; }
        bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
        bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
        bind "d" { HalfPageScrollDown; }
        bind "u" { HalfPageScrollUp; }
        // uncomment this and adjust key if using copy_on_select=false
        // bind "Alt c" { Copy; }
    }
    search {
        bind "Ctrl c" { ScrollToBottom; SwitchToMode "Locked"; }
        bind "j" "Down" { ScrollDown; }
        bind "k" "Up" { ScrollUp; }
        bind "Ctrl f" "PageDown" "Right" "l" { PageScrollDown; }
        bind "Ctrl b" "PageUp" "Left" "h" { PageScrollUp; }
        bind "d" { HalfPageScrollDown; }
        bind "u" { HalfPageScrollUp; }
        bind "n" { Search "down"; }
        bind "p" { Search "up"; }
        bind "c" { SearchToggleOption "CaseSensitivity"; }
        bind "w" { SearchToggleOption "Wrap"; }
        bind "o" { SearchToggleOption "WholeWord"; }
    }
    entersearch {
        bind "Ctrl c" "Esc" { SwitchToMode "Scroll"; }
        bind "Enter" { SwitchToMode "Search"; }
    }
    renametab {
        bind "Esc" { UndoRenameTab; SwitchToMode "Tab"; }
    }
    renamepane {
        bind "Esc" { UndoRenamePane; SwitchToMode "Pane"; }
    }
    session {
        bind "s" { SwitchToMode "Scroll"; }
        bind "d" { Detach; }
        bind "w" {
            LaunchOrFocusPlugin "zellij:session-manager" {
                floating true
                move_to_focused_tab true
            };
            SwitchToMode "Normal"
        }
    }
    tmux {
        bind "[" { SwitchToMode "Scroll"; }
        bind "Ctrl b" { Write 2; SwitchToMode "Normal"; }
        bind "\"" { NewPane "Down"; SwitchToMode "Normal"; }
        bind "%" { NewPane "Right"; SwitchToMode "Normal"; }
        bind "z" { ToggleFocusFullscreen; SwitchToMode "Normal"; }
        bind "c" { NewTab; SwitchToMode "Normal"; }
        bind "," { SwitchToMode "RenameTab"; }
        bind "p" { GoToPreviousTab; SwitchToMode "Normal"; }
        bind "n" { GoToNextTab; SwitchToMode "Normal"; }
        bind "Left" { MoveFocus "Left"; SwitchToMode "Normal"; }
        bind "Right" { MoveFocus "Right"; SwitchToMode "Normal"; }
        bind "Down" { MoveFocus "Down"; SwitchToMode "Normal"; }
        bind "Up" { MoveFocus "Up"; SwitchToMode "Normal"; }
        bind "h" { MoveFocus "Left"; SwitchToMode "Normal"; }
        bind "l" { MoveFocus "Right"; SwitchToMode "Normal"; }
        bind "j" { MoveFocus "Down"; SwitchToMode "Normal"; }
        bind "k" { MoveFocus "Up"; SwitchToMode "Normal"; }
        bind "o" { FocusNextPane; }
        bind "d" { Detach; }
        bind "Space" { NextSwapLayout; }
        bind "x" { CloseFocus; SwitchToMode "Normal"; }
    }

    shared_except "locked" {
        bind "Ctrl q" { Quit; }
        bind "Alt c" { Copy; }
        bind "Ctrl g" "Ctrl c" "Enter" "Esc" { SwitchToMode "Locked"; }
        bind "Alt n" { NewPane; }
        bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; }
        bind "Alt l" "Alt Right" { MoveFocusOrTab "Right"; }
        bind "Alt j" "Alt Down" { MoveFocus "Down"; }
        bind "Alt k" "Alt Up" { MoveFocus "Up"; }
        bind "Alt =" "Alt +" { Resize "Increase"; }
        bind "Alt -" { Resize "Decrease"; }
        bind "Alt [" { PreviousSwapLayout; }
        bind "Alt ]" { NextSwapLayout; }
    }
    shared_except "locked" "renamepane" "renametab" "entersearch" {
        bind "1" { GoToTab 1; }
        bind "2" { GoToTab 2; }
        bind "3" { GoToTab 3; }
        bind "4" { GoToTab 4; }
        bind "5" { GoToTab 5; }
        bind "6" { GoToTab 6; }
        bind "7" { GoToTab 7; }
        bind "8" { GoToTab 8; }
        bind "9" { GoToTab 9; }
    }
}

In this way, zellij becomes a terminal multiplexer similar to VIM mode.
This is the modification of zellij code

diff --git a/zellij-utils/src/input/keybinds.rs b/zellij-utils/src/input/keybinds.rs
index ab13f71..822e665 100644
--- a/zellij-utils/src/input/keybinds.rs
+++ b/zellij-utils/src/input/keybinds.rs
@@ -47,7 +47,7 @@ impl Keybinds {
     }
     pub fn default_action_for_mode(&self, mode: &InputMode, raw_bytes: Vec<u8>) -> Action {
         match *mode {
-            InputMode::Normal | InputMode::Locked => Action::Write(raw_bytes),
+            InputMode::Locked => Action::Write(raw_bytes),
             InputMode::RenameTab => Action::TabNameInput(raw_bytes),
             InputMode::RenamePane => Action::PaneNameInput(raw_bytes),
             InputMode::EnterSearch => Action::SearchInput(raw_bytes),

@MatrixManAtYrService
Copy link

MatrixManAtYrService commented Jun 27, 2024

I took @mkon's approach, but I'm using home manger to generate both wezterm/wezterm.lua and zellij/config.kdl, so I ended up with entries like:

wezterm:

config.keys = {
  {key="p", mods="CTRL|SHIFT", action=wezterm.action.SendString("@ctrl_shift_p@")},

zellij:

bind "@ctrl_shift_p@" { SwitchToMode "Normal"; }

...where the @ctrl_shift_p@ is resolved when my config gets built. In retrospect, it was overkill, but here it is anyway.

Without home-manager the entries for wezterm would be like:

config.keys = {
  {key="p", mods="CTRL|SHIFT", action=wezterm.action.SendString("\u{E116}")},

This breaks the user-facing hotkey strings. It would be an even nicer workaround if I could just set them explicitly, but I'm happy enough with it 🙂 .
Screenshot 2024-06-27 at 12 22 51 PM

@Armadillidiid
Copy link

My workaround for this for anyone interested:

Essentially in your terminal, you can bind key combinations to PUS escape codes, example in alacritty:

[keyboard]
bindings = [
  { key = "Left",  mods = "Command",     chars = "\uE000" },
  { key = "Right", mods = "Command",     chars = "\uE001" },
  { key = "Up",    mods = "Command",     chars = "\uE002" },
  { key = "Down",  mods = "Command",     chars = "\uE003" },
  { key = "-",     mods = "Command",     chars = "\uE016" },
  { key = "+",     mods = "Command",     chars = "\uE017" },
  { key = "[",     mods = "Command",     chars = "\uE023" },
  { key = "]",     mods = "Command",     chars = "\uE024" },
  { key = "Enter", mods = "Command",     chars = "\uE026" },
  { key = "F",     mods = "Command",     chars = "\uE106" },
  { key = "G",     mods = "Command",     chars = "\uE107" },
  { key = "I",     mods = "Command",     chars = "\uE109" },
  { key = "P",     mods = "Command",     chars = "\uE116" },
  { key = "S",     mods = "Command",     chars = "\uE119" },
  { key = "T",     mods = "Command",     chars = "\uE120" },
  { key = "W",     mods = "Command",     chars = "\uE123" },
  { key = "M",     mods = "Command|Alt", chars = "\uE165" },
  { key = "O",     mods = "Command|Alt", chars = "\uE167" },
  { key = "P",     mods = "Command|Alt", chars = "\uE168" },
  { key = "R",     mods = "Command|Alt", chars = "\uE170" },
  { key = "S",     mods = "Command|Alt", chars = "\uE171" },
  { key = "T",     mods = "Command|Alt", chars = "\uE172" },
]

Then in zellij you can bind these key codes, replacing the defaults. Then there should be no more collisions. You just have to press this combination when editing the config and it will insert these characters, but the binding will work.

It will look something like this probably, maybe a bit different depending on the font you use:

    shared_except "locked" {
        bind "" { SwitchToMode "Locked"; }
        // bind "Ctrl q" { Quit; }
        bind "" { NewPane "Down"; } // Cmd-Enter
        bind "" { ToggleFloatingPanes; }
        bind "" { NewTab; } // Cmd-T
        bind "" { MoveFocusOrTab "Left"; }
        bind "" { MoveFocusOrTab "Right"; }
        bind "" { MoveFocus "Down"; }
        bind "" { MoveFocus "Up"; }
        bind "" { Resize "Increase"; }
        bind "" { Resize "Decrease"; }
        bind "" { PreviousSwapLayout; }
        bind "" { NextSwapLayout; }
    }

I essentially use Command+Alt+(P,T,O,...) and Command+Arrows to move. Don't even have to use Locking.

I attempted your workaround on Kitty but some for weird reason, Zellij seems to be registering the commands twice. For example, when I try to open a new tab, it creates two tabs instead of one.

    shared {
      bind "" { GoToNextTab; }
      bind "" { GoToPreviousTab; }
      bind "" { NewTab; }
      bind "" { MoveTab "Left"; }
      bind "" { MoveTab "Right"; }
      bind "" { GoToTab 1; }
      bind "" { GoToTab 2; }
      bind "" { GoToTab 3; }
      bind "" { GoToTab 4; }
      bind "" { GoToTab 5; }
      bind "" { GoToTab 6; }
      bind "" { GoToTab 7; }
      bind "" { GoToTab 8; }
      bind "" { GoToTab 9; }
      bind "" { CloseTab; }
    }

@Armadillidiid
Copy link

My workaround for this for anyone interested:
Essentially in your terminal, you can bind key combinations to PUS escape codes, example in alacritty:

[keyboard]
bindings = [
  { key = "Left",  mods = "Command",     chars = "\uE000" },
  { key = "Right", mods = "Command",     chars = "\uE001" },
  { key = "Up",    mods = "Command",     chars = "\uE002" },
  { key = "Down",  mods = "Command",     chars = "\uE003" },
  { key = "-",     mods = "Command",     chars = "\uE016" },
  { key = "+",     mods = "Command",     chars = "\uE017" },
  { key = "[",     mods = "Command",     chars = "\uE023" },
  { key = "]",     mods = "Command",     chars = "\uE024" },
  { key = "Enter", mods = "Command",     chars = "\uE026" },
  { key = "F",     mods = "Command",     chars = "\uE106" },
  { key = "G",     mods = "Command",     chars = "\uE107" },
  { key = "I",     mods = "Command",     chars = "\uE109" },
  { key = "P",     mods = "Command",     chars = "\uE116" },
  { key = "S",     mods = "Command",     chars = "\uE119" },
  { key = "T",     mods = "Command",     chars = "\uE120" },
  { key = "W",     mods = "Command",     chars = "\uE123" },
  { key = "M",     mods = "Command|Alt", chars = "\uE165" },
  { key = "O",     mods = "Command|Alt", chars = "\uE167" },
  { key = "P",     mods = "Command|Alt", chars = "\uE168" },
  { key = "R",     mods = "Command|Alt", chars = "\uE170" },
  { key = "S",     mods = "Command|Alt", chars = "\uE171" },
  { key = "T",     mods = "Command|Alt", chars = "\uE172" },
]

Then in zellij you can bind these key codes, replacing the defaults. Then there should be no more collisions. You just have to press this combination when editing the config and it will insert these characters, but the binding will work.
It will look something like this probably, maybe a bit different depending on the font you use:

    shared_except "locked" {
        bind "" { SwitchToMode "Locked"; }
        // bind "Ctrl q" { Quit; }
        bind "" { NewPane "Down"; } // Cmd-Enter
        bind "" { ToggleFloatingPanes; }
        bind "" { NewTab; } // Cmd-T
        bind "" { MoveFocusOrTab "Left"; }
        bind "" { MoveFocusOrTab "Right"; }
        bind "" { MoveFocus "Down"; }
        bind "" { MoveFocus "Up"; }
        bind "" { Resize "Increase"; }
        bind "" { Resize "Decrease"; }
        bind "" { PreviousSwapLayout; }
        bind "" { NextSwapLayout; }
    }

I essentially use Command+Alt+(P,T,O,...) and Command+Arrows to move. Don't even have to use Locking.

I attempted your workaround on Kitty but some for weird reason, Zellij seems to be registering the commands twice. For example, when I try to open a new tab, it creates two tabs instead of one.

    shared {
      bind "" { GoToNextTab; }
      bind "" { GoToPreviousTab; }
      bind "" { NewTab; }
      bind "" { MoveTab "Left"; }
      bind "" { MoveTab "Right"; }
      bind "" { GoToTab 1; }
      bind "" { GoToTab 2; }
      bind "" { GoToTab 3; }
      bind "" { GoToTab 4; }
      bind "" { GoToTab 5; }
      bind "" { GoToTab 6; }
      bind "" { GoToTab 7; }
      bind "" { GoToTab 8; }
      bind "" { GoToTab 9; }
      bind "" { CloseTab; }EDIT: I had comments of the PUA Unicode (for easy reference) on the same line as the mapping in my `kitty.conf`. Unknowingly, it was registering both of them. I shifted it to separate lines, and it worked perfectly.
    }

EDIT: I had comments of the PUA Unicode (for easy reference) on the same line as the mapping in my kitty.conf. Unknowingly, it was registering both of them. I shifted it to separate lines, and it worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action Issues related to actions help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests