23fe53eb5f9cafb5d6e719d51b241a55dc85c150

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #2634 from danchenkov/master

added terminfo keys verification

Diff

 1diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
 2index 94f1842f37b5f38a5c6387ec6aae243af0820e34..5f3f237c72b6408fe4233ab7b7eab6f3365c326b 100644
 3--- a/lib/key-bindings.zsh
 4+++ b/lib/key-bindings.zsh
 5@@ -15,29 +15,49 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
 6   zle -N zle-line-finish
 7 fi
 8 
 9-bindkey -e                                          # Use emacs key bindings
10+bindkey -e                                            # Use emacs key bindings
11 
12-bindkey '\ew' kill-region                           # [Esc-w] - Kill from the cursor to the mark
13-bindkey -s '\el' 'ls\n'                             # [Esc-l] - run command: ls
14-bindkey '^r' history-incremental-search-backward    # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
15-bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history
16-bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history
17+bindkey '\ew' kill-region                             # [Esc-w] - Kill from the cursor to the mark
18+bindkey -s '\el' 'ls\n'                               # [Esc-l] - run command: ls
19+bindkey '^r' history-incremental-search-backward      # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
20+if [[ "${terminfo[kpp]}" != "" ]]; then
21+  bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history
22+fi
23+if [[ "${terminfo[knp]}" != "" ]]; then
24+  bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history
25+fi
26 
27-bindkey "${terminfo[kcuu1]}" up-line-or-search      # start typing + [Up-Arrow] - fuzzy find history forward
28-bindkey "${terminfo[kcud1]}" down-line-or-search    # start typing + [Down-Arrow] - fuzzy find history backward
29+if [[ "${terminfo[kcuu1]}" != "" ]]; then
30+  bindkey "${terminfo[kcuu1]}" up-line-or-search      # start typing + [Up-Arrow] - fuzzy find history forward
31+fi
32+if [[ "${terminfo[kcud1]}" != "" ]]; then
33+  bindkey "${terminfo[kcud1]}" down-line-or-search    # start typing + [Down-Arrow] - fuzzy find history backward
34+fi
35 
36-bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line
37-bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line
38+if [[ "${terminfo[khome]}" != "" ]]; then
39+  bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line
40+fi
41+if [[ "${terminfo[kend]}" != "" ]]; then
42+  bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line
43+fi
44 
45-bindkey ' ' magic-space                             # [Space] - do history expansion
46+bindkey ' ' magic-space                               # [Space] - do history expansion
47 
48-bindkey '^[[1;5C' forward-word                      # [Ctrl-RightArrow] - move forward one word
49-bindkey '^[[1;5D' backward-word                     # [Ctrl-LeftArrow] - move backward one word
50+bindkey '^[[1;5C' forward-word                        # [Ctrl-RightArrow] - move forward one word
51+bindkey '^[[1;5D' backward-word                       # [Ctrl-LeftArrow] - move backward one word
52 
53-bindkey "${terminfo[kcbt]}" reverse-menu-complete   # [Shift-Tab] - move through the completion menu backwards
54+if [[ "${terminfo[kdch1]}" != "" ]]; then
55+  bindkey "${terminfo[kdch1]}" reverse-menu-complete  # [Shift-Tab] - move through the completion menu backwards
56+fi
57 
58-bindkey '^?' backward-delete-char                   # [Backspace] - delete backward
59-bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
60+bindkey '^?' backward-delete-char                     # [Backspace] - delete backward
61+if [[ "${terminfo[kdch1]}" != "" ]]; then
62+  bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
63+else
64+  bindkey "^[[3~" delete-char
65+  bindkey "^[3;5~" delete-char
66+  bindkey "\e[3~" delete-char
67+fi
68 
69 # Edit the current command line in $EDITOR
70 autoload -U edit-command-line