[input] check for null bindkey values

Only bind keys if length of var > 0

Hopefully these are the only keys that will require this testing. If
anyone encounters issues like issue #17 with additional keys, please
create an issue.

Closes #17
This commit is contained in:
Matt Hamilton 2016-01-09 05:27:55 -05:00
parent d13614e3bb
commit aef41e25c5

View File

@ -43,8 +43,9 @@ key_info=(
'BackTab' "${terminfo[kcbt]}" 'BackTab' "${terminfo[kcbt]}"
) )
local key
# Bind the keys # Bind the keys
local key
for key in "${(s: :)key_info[ControlLeft]}"; do for key in "${(s: :)key_info[ControlLeft]}"; do
bindkey ${key} backward-word bindkey ${key} backward-word
done done
@ -52,10 +53,18 @@ for key in "${(s: :)key_info[ControlRight]}"; do
bindkey ${key} forward-word bindkey ${key} forward-word
done done
if [[ -n "${key_info[Home]}" ]]; then
bindkey "${key_info[Home]}" beginning-of-line bindkey "${key_info[Home]}" beginning-of-line
bindkey "${key_info[End]}" end-of-line fi
if [[ -n "${key_info[End]}" ]]; then
bindkey "${key_info[End]}" end-of-line
fi
if [[ -n "${key_info[Insert]}" ]]; then
bindkey "${key_info[Insert]}" overwrite-mode bindkey "${key_info[Insert]}" overwrite-mode
fi
bindkey "${key_info[Delete]}" delete-char bindkey "${key_info[Delete]}" delete-char
bindkey "${key_info[Backspace]}" backward-delete-char bindkey "${key_info[Backspace]}" backward-delete-char
@ -69,7 +78,9 @@ bindkey ' ' magic-space
bindkey "${key_info[Control]}L" clear-screen bindkey "${key_info[Control]}L" clear-screen
# Bind Shift + Tab to go to the previous menu item. # Bind Shift + Tab to go to the previous menu item.
if [[ -n "${key_info[BackTab]}" ]]; then
bindkey "${key_info[BackTab]}" reverse-menu-complete bindkey "${key_info[BackTab]}" reverse-menu-complete
fi
# Put into application mode and validate ${terminfo} # Put into application mode and validate ${terminfo}
zle-line-init() { zle-line-init() {