🗒 Bindkeys マップ
Bindkey
The bindkey
key mappings can be very confusing to decipher. It can use multiple different notations but it's smart to use the same key notation throughout your configuration. You can print all of your current key bindings in the current keymap with bindkey
. To print the full bindkey
command to add to your .zshrc
file use bindkey -L
.
In general, you'll bind a widget so a key sequence or a key with a modifier. This can be declared in caret notation using ^
, using escape sequences using \
, in octal (\NNN
), hex (\xNN
), or Unicode (\uNNNN
). None of these are particularly great for people to read. This is also tricky because it depends on your keyboard, operating system, and shell.
次に、いくつかの例を示します:
\e
,\E
, = Escape^[
= Alt key (on some keyboards this is the same as escape)^?
= Delete^X
,^
= Control
The keys that come after the modifier can add more confusion.
Delete key binding
To delete a key binding you can use bindkey -d $KEYS
. Make sure you don't delete the characters you need for typing.
The bindmap'…'
keybindings
Sometimes plugins call bindkey to assign keyboard shortcuts. This can cause problems because multiple plugins can bind the same keys.
Also, the user might want a different binding(s), which will require complicated, additional bindkey
commands in .zshrc
.
Zi provides a solution to this problem – the ability to remap the bindkeys with a short ice-modifier bindmap'…'
.
Examples for bindmap'…'
Map Ctrl-G instead of Ctrl-R for the history searcher.
zi bindmap'^R -> ^G' for z-shell/history-search-multi-word
Map Ctrl-Shift-Left and Ctrl-Shift-Right used by URxvt instead of the Xterms' ones. Load with the bindkey-tracking ↔ with light-loading for anything else.
Could also separate the bindmaps with a semicolon, i.e.:
bindmap'"\\e[1\;6D" -> \\e[1\;5D ; "\\e[1\;6C" -> ^[[1\;5C' \
zi wait light-mode trackbinds bindmap'"\\e[1\;6D" -> \\e[1\;5D"' \
bindmap'"\\e[1\;6C" -> ^[[1\;5C' pick'dircycle.zsh' for \
michaelxmcbride/zsh-dircycle