README: bind arrow keys after observing key codes
Don't suggest using $terminfo[kcuu1] or $terminfo[cuu1] lookups anymore! Instead, have the user observe the actual key codes for their arrow keys using `cat -v` and then use those observed values to create keybindings. This should eliminate confusion and complaints about binding arrow keys. See https://github.com/zsh-users/zsh-history-substring-search/issues/63
This commit is contained in:
parent
6008552895
commit
2f8a21062c
1 changed files with 12 additions and 17 deletions
25
README.md
25
README.md
|
|
@ -32,30 +32,25 @@ Usage
|
|||
% source zsh-syntax-highlighting.zsh
|
||||
% source zsh-history-substring-search.zsh
|
||||
|
||||
2. Bind keyboard shortcuts to this script's functions:
|
||||
2. Bind keyboard shortcuts to this script's functions.
|
||||
|
||||
## Arrow Keys ###########################################
|
||||
Arrow keys:
|
||||
* Run `cat -v` in your favorite terminal emulator to observe key codes.
|
||||
* Press the UP arrow key and observe what is printed in your terminal.
|
||||
* Press the DOWN arrow key and observe what is printed in your terminal.
|
||||
* Press the Control and C keys simultaneously to terminate the `cat -v`.
|
||||
* Use your observations from the previous steps to create key bindings.
|
||||
For example, if you observed `^[[A` for UP and `^[[B` for DOWN, then:
|
||||
|
||||
# OPTION 1: for most systems
|
||||
zmodload zsh/terminfo
|
||||
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
||||
bindkey "$terminfo[kcud1]" history-substring-search-down
|
||||
|
||||
# OPTION 2: for iTerm2 running on Apple MacBook laptops
|
||||
zmodload zsh/terminfo
|
||||
bindkey "$terminfo[cuu1]" history-substring-search-up
|
||||
bindkey "$terminfo[cud1]" history-substring-search-down
|
||||
|
||||
# OPTION 3: for Ubuntu 12.04, Fedora 21, and MacOSX 10.9
|
||||
bindkey '^[[A' history-substring-search-up
|
||||
bindkey '^[[B' history-substring-search-down
|
||||
|
||||
## EMACS mode ###########################################
|
||||
You might also want to bind the Control-P/N keys for use in EMACS mode:
|
||||
|
||||
bindkey -M emacs '^P' history-substring-search-up
|
||||
bindkey -M emacs '^N' history-substring-search-down
|
||||
|
||||
## VI mode ##############################################
|
||||
You might also want to bind the `k` and `j` keys for use in VI mode:
|
||||
|
||||
bindkey -M vicmd 'k' history-substring-search-up
|
||||
bindkey -M vicmd 'j' history-substring-search-down
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue