From 94bc896370495686d61bdb555df535555aed0733 Mon Sep 17 00:00:00 2001 From: tokiclover Date: Wed, 17 Sep 2014 21:39:42 +0200 Subject: [PATCH] modules/editor/init.zsh: additional user key-bindings Added this nice feature to be able to add user defined key-bindings nicely with only/minimul zstyle definitions in *zpreztorc*. --- modules/editor/init.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 9a347a09..8de7c1ec 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -57,6 +57,28 @@ key_info=( 'BackTab' "$terminfo[kcbt]" ) +# Set key_info values from user zstyle defined pairs: terminal/array +zstyle -g terminal ':prezto:module:editor:term' + +for term ($terminal[@]); do + if [[ "${TERM/$term}" != "$TERM" ]]; then + zstyle -a ':prezto:module:editor:term' $term 'bindings' + for key (${(k)binding[@]}); do + key_info[$key]="$bindings[$key]" + done + break + fi +done + +# Else, apply some default values if defined to empty term_info[key] +zstyle -a ':prezto:module:editor:term' default 'bindings' +for key (${(k)default[@]}); do + if [[ -z "$key_info[$key]" ]]; then + key_info[$key]="$default[$key]" + fi +done +unset terminal bindings + # Set empty $key_info values to an invalid UTF-8 sequence to induce silent # bindkey failure. for key in "${(k)key_info[@]}"; do