Skip to content


Key Bindings #12

sorin-ionescu opened this Issue · 4 comments

3 participants

zsh-users member

Should it bind itself, or should it allow the user to bind it manually, and if it should bind itself, should not it bind itself to more keys?

Right now, it only binds itself to the following sequences, which I believe are not valid for all terminals. There are also ^[OA, ^[OB, for example.

bindkey '\e[A' history-substring-search-up
bindkey '\e[B' history-substring-search-down

In my OMZ fork, I actually use $terminfo to get the sequences, but I also bind it to more keys.

bindkey -M emacs "^P" history-substring-search-up
bindkey -M emacs "^N" history-substring-search-down
bindkey -M vicmd "k" history-substring-search-up
bindkey -M vicmd "j" history-substring-search-down

for keymap in 'emacs' 'viins'; do
  bindkey -M "$keymap" '\e[A' history-substring-search-up
  bindkey -M "$keymap" '\e[B' history-substring-search-down
unset keymap

^[0A and ^[0B are exactly what I have to bind myself to get this to work on my Ubuntu terminals. Thanks for this bug report, it helped clue me in as to why this was working great on my Mac but not at all on my Ubuntu machine.

zsh-users member

I have added Sorin's suggestion to a new bindkey branch. Please try it out.

If there are no problems, I'll release it by merging it into the master branch.

zsh-users member

Any feedback on these changes? Shall I merge them into master?

@sunaku sunaku closed this
zsh-users member

@LegionSB and other Ubuntu or Debian users take note!

Adding this snippet to your ~/.zshenv file solves the problem:

# allow UP and DOWN arrow keys in xterm(1) to be re-bindable within ZSH           

This worked for me in Ubuntu 12.10.

@ornicar ornicar added a commit to ornicar/zsh-history-substring-search that referenced this issue
@ornicar ornicar Merge branch 'master' of…

* 'master' of
  we need to bind ^[[A and ^[[B not ^[A and ^[B
  GH-12: fix arrow bindkey and support emacs & vicmd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.