zsh/modules/bindings/init

62 lines
2 KiB
Plaintext
Raw Normal View History

#!/bin/zsh
2016-01-05 02:44:34 +00:00
# Allow <esc>:q in vim mode to exit the shell
exit(){builtin exit;}
zle -N q exit
2016-01-05 02:44:34 +00:00
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
bindkey -M vicmd ! edit-command-line-tmux
#unicode input
autoload -U insert-unicode-char
2016-01-05 02:44:34 +00:00
zle -N insert-unicode-char
bindkey "^Vu" insert-unicode-char
2014-06-27 05:43:45 +00:00
bindkey "\e." insert-last-word
2016-01-05 02:44:34 +00:00
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" yank
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-search
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
bindkey "^[e" expand-cmd-path # C-e for expanding path of typed command.
bindkey " " magic-space # Do history expansion on space.
2014-06-27 05:43:45 +00:00
bindkey $'\177' backward-delete-char #backspace
bindkey $'\10' backward-delete-word #C-backspace
2016-01-05 02:44:34 +00:00
2014-06-27 05:43:45 +00:00
bindkey "\e[1;5D" vi-backward-blank-word
bindkey "\e[1;5C" vi-forward-blank-word
#bindkey . rationalise-dot
2014-06-27 05:43:45 +00:00
bindkey $'\20' push-line-or-edit
2016-01-05 02:44:34 +00:00
bindkey -s "^F" "fuck\n"
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
function zle-line-init () {
echoti smkx
}
function zle-line-finish () {
echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish