Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'bindkey'; closes issue #12

  • Loading branch information...
commit 428ea1059883e1753baa2987057edf2d83bb40cb 2 parents 04c2eca + ebde030
Suraj N. Kurapati sunaku authored

Showing 2 changed files with 21 additions and 2 deletions. Show diff stats Hide diff stats

  1. +1 0  README.md
  2. +20 2 zsh-history-substring-search.zsh
1  README.md
Source Rendered
@@ -4,6 +4,7 @@ zsh-history-substring-search
4 4 This is a clean-room implementation of the [Fish shell][1]'s history search
5 5 feature, where you can type in any part of any previously entered command
6 6 and press the UP and DOWN arrow keys to cycle through the matching commands.
  7 +You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same.
7 8
8 9 [1]: http://fishshell.com
9 10 [2]: http://www.zsh.org/mla/users/2009/msg00818.html
22 zsh-history-substring-search.zsh
@@ -72,8 +72,26 @@ function history-substring-search-down() {
72 72 zle -N history-substring-search-up
73 73 zle -N history-substring-search-down
74 74
75   -bindkey '\e[A' history-substring-search-up
76   -bindkey '\e[B' history-substring-search-down
  75 +#-----------------------------------------------------------------------------
  76 +# shortcut key bindings
  77 +#-----------------------------------------------------------------------------
  78 +
  79 +# bind P and N for EMACS mode
  80 +bindkey -M emacs '^P' history-substring-search-up
  81 +bindkey -M emacs '^N' history-substring-search-down
  82 +
  83 +# bind k and j for VI mode
  84 +bindkey -M vicmd 'k' history-substring-search-up
  85 +bindkey -M vicmd 'j' history-substring-search-down
  86 +
  87 +# bind up and down arrow keys
  88 +for keymap in 'emacs' 'viins'; do
  89 + for keycode in '' '0'; do
  90 + bindkey -M $keymap '\e['$keycode'A' history-substring-search-up
  91 + bindkey -M $keymap '\e['$keycode'B' history-substring-search-down
  92 + done
  93 +done
  94 +unset keymap keycode
77 95
78 96 #-----------------------------------------------------------------------------
79 97 # implementation details

0 comments on commit 428ea10

Please sign in to comment.
Something went wrong with that request. Please try again.