- How to add customized event and bind keymap
- The very beginner to zle of zsh keymapping with bindkey
double-up-history() { zle up-history; zle up-history }
zle -N double-up-history
In this example bind alphabet "d".
bindkey d double-up-history
echo 1
1
echo 2
2
echo 3
3
# hit d
echo 2
You will see echo 2
not echo 3
.
upto-history twice succceded!
Let’s bind now created custom widget `double-up-history to another key!
b
bi
bin
echo 2
echo 2k
echo 2ke
echo 2key
Remember you binded keymap "d" to double-up-history
widget.
So you can not hit "d" alphabet never.
But do not warry. Once close your console and re-opening resolves that problem.
All customized mapped bindkey will be reset.
source ~/.zshrc
double-up-history() {
zle up-history
zle up-history
}
zle -N double-up-history
bindkey d double-up-history
- zsh 5.5.1 (x86_64-apple-darwin17.5.0)