From 628dc0646915e9e180cd7d97077b564d7da6b26a Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 4 Feb 2009 11:49:46 +0100 Subject: [KeyBindings] vi-mode --- user:hugues/Environment.zsh | 2 +- user:hugues/KeyBindings.zsh | 69 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/user:hugues/Environment.zsh b/user:hugues/Environment.zsh index 1ea0670..2e4d302 100644 --- a/user:hugues/Environment.zsh +++ b/user:hugues/Environment.zsh @@ -48,7 +48,7 @@ TIMEFMT='`%J` -- %P cpu System %S Total %E' -KEYTIMEOUT=1 +KEYTIMEOUT=1 # 0,01 sec # Displays who is logging in or out WATCHFMT=$c_$color[bold]$_c"%n"$c_$color[none]$_c" has "$c_$color[bold]$_c"%a"$c_$color[none]$_c" %l from %M" diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh index 3d9971b..07327f3 100644 --- a/user:hugues/KeyBindings.zsh +++ b/user:hugues/KeyBindings.zsh @@ -50,12 +50,69 @@ test $TERM = 'xterm' && # npo : which-command est sur ESC-? par defaut # Lancez ``bindkey'' pour en savoir plus !! -bindkey -A vicmd main ; source $0:h/Bindings -bindkey -s 'Q' 'ixpush-line ' -bindkey -s 'q' 'ixpush-line ' -bindkey -A viins main ; source $0:h/Bindings +main=viins +# Vi-mode +bindkey -A main $main + +for keymap in viins vicmd +do + bindkey -M $keymap -s 'r' 'Q rehash\n' + bindkey -M $keymap -s 'R' 'Q reset\n' + + bindkey -M $keymap -s 't' 'Q todo\n' + #bindkey -M $keymap -s 'T' 'Q todo all -c\n' + + bindkey -M $keymap -s 'é' ' 2>/dev/null ' + bindkey -M $keymap -s '2' ' 2>&1 ' + + bindkey -M $keymap -s 'm' 'Q make\n' + bindkey -M $keymap -s 'M' 'Q make\n' + + bindkey -M $keymap -s 'l' 'Q l\n' + + bindkey -M $keymap -s ' ' '\\ ' + + bindkey -M $keymap -s 'g' 'Q git-status\n' + bindkey -M $keymap -s 'G' 'Q git-repack -d -a\n' + + bindkey -M $keymap -s 'S' 'Q sudo !!' + + bindkey -M $keymap -s 'X' 'Q exec zsh\n' +done + +# redefines push-line +bindkey -M viins "q" push-line +bindkey -M viins "Q" push-line +bindkey -M vicmd -s "q" "iq" +bindkey -M vicmd -s "Q" "iQ" + +# Sets vicmd-mode vim-compliant +bindkey -M vicmd "u" "undo" +bindkey -M vicmd "" "redo" +bindkey -M vicmd "j" "history-search-forward" +bindkey -M viins "j" "history-search-forward" +bindkey -M vicmd "k" "history-search-backward" +bindkey -M viins "k" "history-search-backward" + + +menuselect_vi-mode() +{ + # Sets menuselect vim-compliant + bindkey -M menuselect "j" "down-line-or-history" + bindkey -M menuselect "k" "up-line-or-history" + bindkey -M menuselect "h" "backward-char" + bindkey -M menuselect "l" "forward-char" +} # Enters vi-cmd mode at each prompt -zle-line-init() { zle vi-cmd-mode } -zle -N zle-line-init +#zle-line-init() { zle vi-cmd-mode } +#zle -N zle-line-init +# Show the current keymap used +zle-keymap-select() +{ + local keymap=$( [ $KEYMAP = "main" ] && echo "$main" || echo $KEYMAP ) + term_title " [$keymap]" +} +zle -N zle-keymap-select +zle -N zle-line-init zle-keymap-select -- cgit v1.2.3