I'm learning zsh
at the moment, and configuring my ~/.zshrc
. On the Archwiki, I found a snippet to change the history searching behavior:
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
[[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search
[[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search
After scouring the man
pages however, I cannot find any documentation on the key
keyword or what parameters it can take. grep
-ing for man zshall | grep -i "key.*\["
does not show any more information, nor does the man zshzle
entry for bindkey
. The closest relevant match is the following from man zshcontrib
:
...
source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE
[[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
[[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char
# etc.
...
I found more examples at zshwiki and an answer from @rayandrews on Unix.SE, although neither appear to be or claim to be the full list of parameters to key
, nor describe where/how key
is defined.
Where can I learn more about key[...]
and how to use it?
zkbd
, which created anxterm-256color-:0
file for me. It doesn't contain any more info than I already had unfortunately, but I can add the contents to my post if you think it's helpful. – nivk Jul 15 '17 at 22:49kdch1
) and the example uses a more understandable Delete. In regard to your question, the parameter tokey
is the user-assigned name. Someone could define additional names, but there's no "full list". – Thomas Dickey Jul 15 '17 at 22:56key[...]
is just a dictionary for the more opaqueterminfo
parameters. But I have not defined this dictionary anywhere, so (in the Archwiki example) how does$key[Up]
not throw an error? Thekey
dictionary must exist somewhere on my machine, no? – nivk Jul 15 '17 at 23:11pacman
should have something to list the contents of a package, and from that you could grep for things that would be in the hash, to see wherekey
is populated). – Thomas Dickey Jul 15 '17 at 23:34