e537ee9db95966af3439b550c15d8971805c73cf

Author
Alexei Danchenkov <adanchenkov@gmail.com>
Committer
Alexei Danchenkov <adanchenkov@gmail.com>
Date

Message

added terminfo keys verification

Diff

 1diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
 2index 94f1842f37b5f38a5c6387ec6aae243af0820e34..33046b0f108bf358e6da54715f843a8a28125fd5 100644
 3--- a/lib/key-bindings.zsh
 4+++ b/lib/key-bindings.zsh
 5@@ -20,24 +20,40 @@ bindkey -e                                          # Use emacs key bindings
 6 bindkey '\ew' kill-region                           # [Esc-w] - Kill from the cursor to the mark
 7 bindkey -s '\el' 'ls\n'                             # [Esc-l] - run command: ls
 8 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.
 9-bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history
10-bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history
11+if [[ "${terminfo[kpp]}" != "" ]]; then
12+  bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history
13+fi
14+if [[ "${terminfo[knp]}" != "" ]]; then
15+  bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history
16+fi
17 
18-bindkey "${terminfo[kcuu1]}" up-line-or-search      # start typing + [Up-Arrow] - fuzzy find history forward
19-bindkey "${terminfo[kcud1]}" down-line-or-search    # start typing + [Down-Arrow] - fuzzy find history backward
20+if [[ "${terminfo[kcuu1]}" != "" ]]; then
21+  bindkey "${terminfo[kcuu1]}" up-line-or-search      # start typing + [Up-Arrow] - fuzzy find history forward
22+fi
23+if [[ "${terminfo[kcud1]}" != "" ]]; then
24+  bindkey "${terminfo[kcud1]}" down-line-or-search    # start typing + [Down-Arrow] - fuzzy find history backward
25+fi
26 
27-bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line
28-bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line
29+if [[ "${terminfo[khome]}" != "" ]]; then
30+  bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line
31+fi
32+if [[ "${terminfo[kend]}" != "" ]]; then
33+  bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line
34+fi
35 
36 bindkey ' ' magic-space                             # [Space] - do history expansion
37 
38 bindkey '^[[1;5C' forward-word                      # [Ctrl-RightArrow] - move forward one word
39 bindkey '^[[1;5D' backward-word                     # [Ctrl-LeftArrow] - move backward one word
40 
41-bindkey "${terminfo[kcbt]}" reverse-menu-complete   # [Shift-Tab] - move through the completion menu backwards
42+if [[ "${terminfo[kdch1]}" != "" ]]; then
43+  bindkey "${terminfo[kdch1]}" reverse-menu-complete   # [Shift-Tab] - move through the completion menu backwards
44+fi
45 
46 bindkey '^?' backward-delete-char                   # [Backspace] - delete backward
47-bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
48+if [[ "${terminfo[kdch1]}" != "" ]]; then
49+  bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
50+fi
51 
52 # Edit the current command line in $EDITOR
53 autoload -U edit-command-line