Can anyone tell me what the key sequence is for these?
I know if I do cat
and type key presses I can get the code for it but how do I reverse that process to figure out what to press for beginning-of-line, for example?
bindkey '^[^[[D' backward-word
bindkey '^[^[[C' forward-word
bindkey '^[[5~' up-line-or-history
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
bindkey '^[[6~' down-line-or-history
bindkey '^[[5D' beginning-of-line
bindkey '^[[5C' end-of-line
bindkey '^[[3~' delete-char
bindkey '^?' backward-delete-char
bindkey '^[^N' newtab
bindkey '^[[Z' reverse-menu-complete
Tip: I've now published a more sophisticated version of the code 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. 🙂
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With