From aef41e25c57e2fa198237b7d5233ca1dc79325bf Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Sat, 9 Jan 2016 05:27:55 -0500 Subject: [PATCH] [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 --- modules/input/init.zsh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/input/init.zsh b/modules/input/init.zsh index 3dd9f26..a1f9458 100644 --- a/modules/input/init.zsh +++ b/modules/input/init.zsh @@ -43,8 +43,9 @@ key_info=( 'BackTab' "${terminfo[kcbt]}" ) -local key # Bind the keys + +local key for key in "${(s: :)key_info[ControlLeft]}"; do bindkey ${key} backward-word done @@ -52,10 +53,18 @@ for key in "${(s: :)key_info[ControlRight]}"; do bindkey ${key} forward-word done -bindkey "${key_info[Home]}" beginning-of-line -bindkey "${key_info[End]}" end-of-line +if [[ -n "${key_info[Home]}" ]]; then + bindkey "${key_info[Home]}" beginning-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 +fi -bindkey "${key_info[Insert]}" overwrite-mode bindkey "${key_info[Delete]}" delete-char bindkey "${key_info[Backspace]}" backward-delete-char @@ -69,7 +78,9 @@ bindkey ' ' magic-space bindkey "${key_info[Control]}L" clear-screen # Bind Shift + Tab to go to the previous menu item. -bindkey "${key_info[BackTab]}" reverse-menu-complete +if [[ -n "${key_info[BackTab]}" ]]; then + bindkey "${key_info[BackTab]}" reverse-menu-complete +fi # Put into application mode and validate ${terminfo} zle-line-init() {