ZSH Bindkey Reverse Lookup
Tip: I've now published a more sophisticated version of thecode below as part of the
zsh-edit
plugin.
You can use this function to do a reverse bindkey lookup:
reverse-bindkey-lookup() { print ${(k)terminfo[(Re)$(print -b - $1)]}}
For example, when I run:
% reverse-bindkey-lookup '^[[Z'
I get as output:
cbt kcbt
These values you can then look up by doing
% man terminfo
and pressing / to search.
For the example above, I find:
back_tab cbt bt back tab (P)
and
key_btab kcbt kB back-tab key
Another example: If I run
% reverse-bindkey-lookup '^[[3~'
I get
kdch1
which man terminfo
says is
key_dc kdch1 kD delete-character key
Hopefully, you can then figure out from there what the actual key on your keyboard would be. 🙂
I have no idea how to do reverse look up in general, just to provide some information for my Terminal (which should mimic xterm
). This is done by Ctrl V (quoted-insert
); replacing ^[
with \e
for clarity.
\e[5~
/\e[6~
are PgUp PgDn\e[A
to\e[D
are arrow keys ↑ ↓ → ←^?
is ← Backspace\e[3~
is Delete