mirror of
https://github.com/zsh-users/zsh-history-substring-search
synced 2024-09-20 16:19:04 +02:00
Merge branch 'bindkey'; closes issue #12
This commit is contained in:
commit
428ea10598
|
@ -4,6 +4,7 @@ zsh-history-substring-search
|
||||||
This is a clean-room implementation of the [Fish shell][1]'s history search
|
This is a clean-room implementation of the [Fish shell][1]'s history search
|
||||||
feature, where you can type in any part of any previously entered command
|
feature, where you can type in any part of any previously entered command
|
||||||
and press the UP and DOWN arrow keys to cycle through the matching commands.
|
and press the UP and DOWN arrow keys to cycle through the matching commands.
|
||||||
|
You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same.
|
||||||
|
|
||||||
[1]: http://fishshell.com
|
[1]: http://fishshell.com
|
||||||
[2]: http://www.zsh.org/mla/users/2009/msg00818.html
|
[2]: http://www.zsh.org/mla/users/2009/msg00818.html
|
||||||
|
|
|
@ -72,8 +72,26 @@ function history-substring-search-down() {
|
||||||
zle -N history-substring-search-up
|
zle -N history-substring-search-up
|
||||||
zle -N history-substring-search-down
|
zle -N history-substring-search-down
|
||||||
|
|
||||||
bindkey '\e[A' history-substring-search-up
|
#-----------------------------------------------------------------------------
|
||||||
bindkey '\e[B' history-substring-search-down
|
# shortcut key bindings
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# bind P and N for EMACS mode
|
||||||
|
bindkey -M emacs '^P' history-substring-search-up
|
||||||
|
bindkey -M emacs '^N' history-substring-search-down
|
||||||
|
|
||||||
|
# bind k and j for VI mode
|
||||||
|
bindkey -M vicmd 'k' history-substring-search-up
|
||||||
|
bindkey -M vicmd 'j' history-substring-search-down
|
||||||
|
|
||||||
|
# bind up and down arrow keys
|
||||||
|
for keymap in 'emacs' 'viins'; do
|
||||||
|
for keycode in '' '0'; do
|
||||||
|
bindkey -M $keymap '\e['$keycode'A' history-substring-search-up
|
||||||
|
bindkey -M $keymap '\e['$keycode'B' history-substring-search-down
|
||||||
|
done
|
||||||
|
done
|
||||||
|
unset keymap keycode
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# implementation details
|
# implementation details
|
||||||
|
|
Loading…
Reference in a new issue