aboutsummaryrefslogtreecommitdiffstats
path: root/_zsh
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-02-08 11:10:34 +0800
committerAaron LI <aaronly.me@outlook.com>2017-02-08 11:10:34 +0800
commit1e2aa6f8dbeeb59a23908b0b01620ee179c2c5dc (patch)
tree9c4cf32bc4c16b5ec89eb470d117b55c5ea384dc /_zsh
parent801b70373f7f7985abcb1916b920e462200654ed (diff)
downloaddotfiles-1e2aa6f8dbeeb59a23908b0b01620ee179c2c5dc.tar.bz2
zsh: Add key bindings for history search in vi-mode
Credit: http://zshwiki.org/home/zle/bindkeys
Diffstat (limited to '_zsh')
-rw-r--r--_zsh/50-vi-mode.zsh13
-rw-r--r--_zsh/70-history.zsh3
2 files changed, 12 insertions, 4 deletions
diff --git a/_zsh/50-vi-mode.zsh b/_zsh/50-vi-mode.zsh
index 4fe2d9e..49c1a26 100644
--- a/_zsh/50-vi-mode.zsh
+++ b/_zsh/50-vi-mode.zsh
@@ -2,11 +2,10 @@
# zsh/vi-mode.zsh
# see zshzle(1)
#
-# NOTE:
-# This will *reset* previous bindkey settings!
-#
# Credits:
-# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/vi-mode/vi-mode.plugin.zsh
+# * https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/vi-mode/vi-mode.plugin.zsh
+# * http://zshwiki.org/home/zle/bindkeys
+#
# 2015-11-18
#
@@ -25,6 +24,8 @@ zle -N zle-keymap-select
zle -N edit-command-line
+# NOTE:
+# This will *reset* previous bindkey settings!
bindkey -v
# allow v to edit the command line (standard behaviour)
@@ -40,6 +41,10 @@ bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
+# allow ctrl-r for incremental history search
+bindkey -M viins '^r' history-incremental-search-backward
+bindkey -M vicmd '^r' history-incremental-search-backward
+
# if mode indicator wasn't setup by theme, define default
if [[ "$MODE_INDICATOR" == "" ]]; then
MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
diff --git a/_zsh/70-history.zsh b/_zsh/70-history.zsh
index 1d6ad6d..efbdb5f 100644
--- a/_zsh/70-history.zsh
+++ b/_zsh/70-history.zsh
@@ -26,6 +26,9 @@ if exists percol; then
zle -N percol_select_history
# Override the bindkey settings in `60-bindkeys.zsh`
bindkey '^R' percol_select_history
+ # Override the bindkey settings in `50-vi-mode.zsh`
+ bindkey -M viins '^r' percol_select_history
+ bindkey -M vicmd '^r' percol_select_history
fi
# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: #