81 lines
2.5 KiB
Bash
81 lines
2.5 KiB
Bash
# vi mode
|
|
bindkey -v
|
|
|
|
zmodload zsh/terminfo
|
|
typeset -gA key_info
|
|
|
|
key_info=(
|
|
'Control' "\C-"
|
|
'Escape' "\e"
|
|
'Meta' "\M-"
|
|
'Backspace' "^?"
|
|
'Delete' "^[[3~"
|
|
'F1' "$terminfo[kf1]"
|
|
'F2' "$terminfo[kf2]"
|
|
'F3' "$terminfo[kf3]"
|
|
'F4' "$terminfo[kf4]"
|
|
'F5' "$terminfo[kf5]"
|
|
'F6' "$terminfo[kf6]"
|
|
'F7' "$terminfo[kf7]"
|
|
'F8' "$terminfo[kf8]"
|
|
'F9' "$terminfo[kf9]"
|
|
'F10' "$terminfo[kf10]"
|
|
'F11' "$terminfo[kf11]"
|
|
'F12' "$terminfo[kf12]"
|
|
'Insert' "$terminfo[kich1]"
|
|
'Home' "$terminfo[khome]"
|
|
'PageUp' "$terminfo[kpp]"
|
|
'End' "$terminfo[kend]"
|
|
'PageDown' "$terminfo[knp]"
|
|
'Up' "$terminfo[kcuu1]"
|
|
'Left' "$terminfo[kcub1]"
|
|
'Down' "$terminfo[kcud1]"
|
|
'Right' "$terminfo[kcuf1]"
|
|
'BackTab' "$terminfo[kcbt]"
|
|
'AltLeft' "${key_info[Escape]}${key_info[Left]} \e[1;3D"
|
|
'AltRight' "${key_info[Escape]}${key_info[Right]} \e[1;3C"
|
|
'ControlLeft' "\e[1;5D"
|
|
'ControlRight' "\e[1;5C"
|
|
'ControlPageUp' "\e[5;5~"
|
|
'ControlPageDown' "\e[6;5~"
|
|
)
|
|
|
|
local -A global_keybinds
|
|
global_keybinds=(
|
|
"$key_info[Home]" beginning-of-line
|
|
"$key_info[End]" end-of-line
|
|
"$key_info[Delete]" delete-char
|
|
"$key_info[ControlLeft]" backward-word
|
|
"$key_info[ControlRight]" forward-word
|
|
"$key_info[Control]E" lf-wrap
|
|
"$key_info[Control]G" lazygit-wrap
|
|
"$key_info[Control]S" toggle-fzf-tab
|
|
"$key_info[Control]Z" fancy-ctrl-z
|
|
"$key_info[Control]J" jq-complete
|
|
)
|
|
|
|
local -A viins_keybinds
|
|
viins_keybinds=(
|
|
"$key_info[Control]W" backward-kill-word
|
|
"$key_info[Backspace]" backward-delete-char
|
|
"$key_info[ControlLeft]" vi-backward-word
|
|
"$key_info[ControlRight]" vi-forward-word
|
|
)
|
|
|
|
local -A vicmd_keybinds
|
|
vicmd_keybinds=(
|
|
"$key_info[Control]V" edit-command-line
|
|
"$key_info[Delete]" delete-char
|
|
"$key_info[ControlLeft]" vi-backward-word
|
|
"$key_info[ControlRight]" vi-forward-word
|
|
"$key_info[Escape]" sudo-command-line
|
|
)
|
|
|
|
for key bind in ${(kv)global_keybinds} ${(kv)viins_keybinds}; do
|
|
bindkey -M viins "$key" "$bind"
|
|
done
|
|
|
|
for key bind in ${(kv)global_keybinds} ${(kv)vicmd_keybinds}; do
|
|
bindkey -M vicmd "$key" "$bind"
|
|
done
|