diff options
Diffstat (limited to 'user:hugues/KeyBindings.zsh')
-rw-r--r-- | user:hugues/KeyBindings.zsh | 93 |
1 files changed, 70 insertions, 23 deletions
diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh index 5666dc3..bfdcba4 100644 --- a/user:hugues/KeyBindings.zsh +++ b/user:hugues/KeyBindings.zsh @@ -40,32 +40,79 @@ test $TERM = 'xterm' && bindkey 'OF' end-of-line # end-of-line } -# -# First pass with my personal bindings in vicmd-mode -# -bindkey -A vicmd main ; source $0:h/Bindings -# And here we re-define the 'push-line' macro -bindkey -s "q" "iq" -bindkey -s "Q" "iQ" - -# Second pass with my personal bindings in viins-mode -bindkey -A viins main ; source $0:h/Bindings - -# Start every line editor in vicmd-mode. -# 'bindkey -A vicmd main' is not the good way since -# there is no way to enter viins-mode !!.. How tricky.. -zle-line-init() { zle vi-cmd-mode } -zle -N zle-line-init -# Go see man zshzle for more details. - -zle-keymap-select() +set_keymap() { - # $1 is the old keymap - # $KEYMAP is the new one + main=$1 + bindkey -A main $main +} +# Vi-mode +set_keymap viins + +for keymap in viins vicmd emacs +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' - local curr="$([ "$KEYMAP" = "main" ] && echo "viins" || echo $KEYMAP)" + bindkey -M $keymap -s 'S' 'Q sudo !!' - term_title " [$curr]" + bindkey -M $keymap -s 'X' 'Q exec zsh\n' + bindkey -M $keymap -s 'OA' 'up-line-or-history' + bindkey -M $keymap -s 'OB' 'down-line-or-history' + bindkey -M $keymap -s 'OC' 'forward-word' + bindkey -M $keymap -s 'OD' 'backward-word' + + bindkey -M $keymap "q" push-line + bindkey -M $keymap "Q" push-line +done + +# redefines push-line for vicmd +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 + +# 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 |