From 2594270fdf86fb5a7e9d558ee2fde1f8f6189562 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 24 Jan 2012 23:39:51 -0500 Subject: [PATCH] Fixed the default keymap selection. --- keyboard.zsh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/keyboard.zsh b/keyboard.zsh index fac062a1..3a102ca9 100644 --- a/keyboard.zsh +++ b/keyboard.zsh @@ -54,18 +54,8 @@ keyinfo=( 'BackTab' "$terminfo[kcbt]" ) -# Use Emacs bindings by default. -if ! zstyle -m ':omz:editor' keymap ' *'; then - zstyle ':omz:editor' keymap 'emacs' -fi - -# Stop binding on an invalid keymap. -if ! zstyle -m ':omz:editor' keymap 'emacs|vi'; then - print "omz: \`zstyle ':omz:editor' keymap\` must be set to 'emacs' or 'vi'" >&2 - return 1 -fi - -if zstyle -m ':omz:editor' keymap 'emacs'; then +zstyle -s ':omz:editor' keymap 'keymap' +if [[ "$keymap" == (emacs|) ]]; then # Use Emacs key bindings. bindkey -e @@ -120,9 +110,7 @@ if zstyle -m ':omz:editor' keymap 'emacs'; then [[ -n "$keyinfo[Control]" ]] && \ bindkey -M emacs "$keyinfo[Control]s" history-incremental-search-forward fi -fi - -if zstyle -m ':omz:editor' keymap 'vi'; then +elif [[ "$keymap" == vi ]]; then # Use vi key bindings. bindkey -v @@ -245,7 +233,12 @@ if zstyle -m ':omz:editor' keymap 'vi'; then [[ -n "$keyinfo[Control]" ]] && \ bindkey -M viins "$keyinfo[Control]s" history-incremental-search-forward fi +else + print "omz: invalid keymap: $keymap" >&2 + unset keymap + return 1 fi +unset keymap # The next key bindings are for both Emacs and Vi. [[ -n "$keyinfo[Home]" ]] && \