![]() perform escape-prefixing), this works fine. In Terminal, with alt set to behave as meta (i.e. I have bindkey -M viins "\en" history-substring-search-up in my zsh config. Thus, some terminal programs will work differently depending on whether the terminal is performing metafication or escape-prefixing, whereas others will work the same.įinally, Hyper in particular seems to have a problem with feeding escape-prefixed bytes to the shell. Meanwhile, other programs contain a layer that automatically translates metafied bytes (most significant bit set) into their escape-prefixed siblings. In zsh for instance, bindkey "\M-x" maps to metafied ASCII x, and bindkey "^[x" (or `bindkey "\ex") maps to escape-prefixed x. In contrast, "Meta" in iTerm means "metafy this byte" and "Esc+" means "escape-prefix this byte"Įven more confusingly, many terminal programs treat escape-prefixed and metafied bytes as completely different, whereas others treat them the same. Thus, Hyper and Terminal restrict the user to this escape-prefixing behavior and don't seem to expose any way to metafy bytes, which means that you can't target zsh bindings like \M-x in Hyper or Terminal. In both cases, you should see ^[k, which is an escape character followed by k. You can confirm this by setting this option, going into the respecting terminal, and pressing Ctrl-k Alt-k (Ctrl-k will bypass shell interpretation for the following character, allowing you to insert it directly). That is because, in both Terminal and Hyper, "use option as meta" means "holding alt generates escape-prepended bytes". Notice that Terminal and Hyper allow only two options for alt, whereas iTerm allows three. Now, what is extremely confusing about the above is that Meta does not mean the same thing in these three apps. And in Hyper, you can set altIsMeta: true. In iTerm2, you can set each option to one of three settings: Normal Meta or Esc+. ![]() Thus in macOS Terminal.app there is an option to "Use Option as Meta key". Some key on the modern keyboard had to be chosen to map to this functionality, and alt became the choice. Shells and other terminal programs like vim continue to reference meta in their configuration. Unfortunately established software was quite slow to change. ![]() Let us refer to bytes preceded by an Esc as "escape-prefixed". Thus pressing meta no longer expressed functionality that was impossible for metaless keyboards, since simultaneously pressing meta and x had the same effect as pressing Esc followed by x. Now, rather than setting the most significant bit, an additional escape ( ^[) byte was prepended. Because it is better for terminals to function consistently across different keyboards, many terminals started to change their interpretation of meta. However, at some point meta keys started disappearing from keyboards. Let us refer to bytes with their most significant bit set as "metafied". For example, in zsh bindkey "\M-x" kill-word binds the ASCII byte code for x, with its most significant bit set, to the kill-word widget. Shells and other terminal programs allowed you to bind these metafied bytes. ASCII with meta turns this into a full 8-bit (1 byte) code. ASCII is a 7-bit code in which the most significant bit is always unset. Traditionally, terminals interpreted the meta modifier to set the most significant bit on a byte. In the past, many keyboards had meta keys. Hyper also appears to have an issue with feeding escape-prefixed bytes to the shell. TLDR: iTerm and Hyper mean different things by "treating alt as meta". I believe I've understood what's going on and figured I'd post here for anybody who is as frustrated as I was: I've been tearing my hair out trying to figure out the relationship between alt, meta and escape, and why some things seem to work in iTerm but not in Hyper.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |