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

Please document escape codes for Alt + [ for macOS terminals #2267

Open
gbirke opened this issue Mar 10, 2023 · 9 comments
Open

Please document escape codes for Alt + [ for macOS terminals #2267

gbirke opened this issue Mar 10, 2023 · 9 comments

Comments

@gbirke
Copy link

gbirke commented Mar 10, 2023

With my current Terminal (iTerm) on macOS I can switch with Alt+Arrow, but all other Alt combinations (resizing, switching layout) insert special characters. The Terminal configuration allows to add mappings for other combinations, but I don't know what hex codes / escape codes to send to the terminal. Is there a list of hex codes for Alt+Some_Char combinations?

@elijahmanor
Copy link

elijahmanor commented Mar 10, 2023

There is an entry in the zellij docs addressing macOS and various terminals regarding the Alt key.

However, there is a much simpler solution than what is outlined in the linked blog post.

I documented it in a private gist I'm building with FAQs from my recent YouTube video covering many new features in zellij.

There is also a trick you need to set for Alacritty, but I haven't updated my private gist with those instructions yet. Kitty and WezTerm work fine out-of-the-box regarding the Alt key.

At some point, I'd like to contribute back some of my findings back to the zellij documentation site.

@gbirke
Copy link
Author

gbirke commented Mar 10, 2023

Thanks for your quick answer! The linked docs only show how to redefine the arrow keys and I have trouble figuring out the general pattern for defining other keys. The link to your private Gist seems to be wrong (or I can't see it because it's private).

I'm using iTerm, not Alacritty or WezTerm. For now, my workaround is to set the left option key to "Esc+" in "Profiles > Keys".

I have made some progress in my research for using hex codes instead of redefining the left Alt key: The documentation recommends hex codes for the arrow keys all start with 0x1b 0x1b 0x5b, which means that they are ANSI escape codes. I guess I could send that escape sequence plus the Alt Key plus the character. I've tried to define the sequence for "Alt+" (increase pane size) as 0x1b 0x1b 0x5b 0x03 0x2b (<esc>[<altModifier>+), but that has the effect of triggering the layout change, zellij seems to receive this as "Alt[" instead of the escape sequence. I have tried other combinations (0x1b 0x1b 0x03 0x2b (<esc><altModifier>+), 0x1b 0x1b 0x2b (<esc>+), 0x1b 0x1b 0x5b 0x03 0x3b 0x2b 0x7b (<esc>[<altModifier>;+ ) but none of them worked, I either got the plus sign plus funny chars or the layout change behavior.

@elijahmanor
Copy link

Sorry @gbirke it was the wrong link. Try again (private gist). With gists "Private" just means it's not searchable, you have to know the exact URL

@imsnif
Copy link
Member

imsnif commented Mar 13, 2023

Hey @gbirke - do <ESC>[ and <ESC>] work for you? (ESC in this case being ASCII 27, so 0x1b in your case.

@TheButlah
Copy link

I documented it in a private gist I'm building

This solved it! I don't think the linked solution for zellij on iterm2 is a good one. We should not have to remap every keycombo that uses alt inside iterm2. Simply setting the left option key to "Esc+" in the profile settings seems like a much better approach.

@smileart
Copy link

I wonder if I'm doing something wrong, but I'm on Zellij 0.36, macOS, kitty with macos_option_as_alt configured to left. All Alt + <whatever> key bindings work for me perfectly well, although I don't see the hotkey hint as shown here https://zellij.dev/news/stacked-panes-swap-layouts/ and Alt-] / Alt-[ don't work for me, although I see VERTICAL as my layout type. 🤔

@vricop
Copy link

vricop commented Mar 25, 2024

I documented it in a private gist I'm building

This solved it! I don't think the linked solution for zellij on iterm2 is a good one. We should not have to remap every keycombo that uses alt inside iterm2. Simply setting the left option key to "Esc+" in the profile settings seems like a much better approach.

Not, that's not a good solution, at least it isn't if you also type in other languages, like French, Spanish, Italian. For those we need alt to behave as option in macOS machines so that we can type characters like these: çéñü...

@nemonik
Copy link

nemonik commented Jun 4, 2024

Since iTerm2 Build 3.5.0, resize etc for me is borked and the zellij docs addressing macOS and various terminals regarding the Alt key are now out of date for addressing... Some assistance please.

@smileart
Copy link

smileart commented Jun 7, 2024

Fixed my issue by removing the old config altogether and generating a new one. Apparently the version of the tool was updating but no config migration happened, hence the Alt-] / Alt-[ weren't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants