1
0
Fork 0
dotfiles/common/.config/zsh/configs/bindings

83 lines
2.4 KiB
Plaintext
Raw Normal View History

2024-06-10 01:45:17 +02:00
#!/bin/zsh
2024-10-16 11:52:11 +02:00
WORDCHARS='*?_-.[]~&;!#$%^(){}<>'
2023-03-29 16:15:06 +02:00
# vi mode
bindkey -v
2024-10-16 11:52:11 +02:00
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
)
local -A viins_keybinds
viins_keybinds=(
"$key_info[Backspace]" backward-delete-char
"$key_info[Control]W" backward-kill-word
"$key_info[ControlLeft]" vi-backward-word
"$key_info[ControlRight]" vi-forward-word
"$key_info[Control]E" lfwrap
"$key_info[Control]G" lg
"$key_info[Control]S" toggle-fzf-tab
)
local -A vicmd_keybinds
vicmd_keybinds=(
"$key_info[Delete]" delete-char
"$key_info[ControlLeft]" vi-backward-word
"$key_info[ControlRight]" vi-forward-word
"$key_info[Control]V" edit-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