123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #- cursor -#
- zle-keymap-select() {
- if [ "${KEYMAP}" = vicmd ]; then
- printf %b '\e[4 q'
- elif [ "${KEYMAP}" = main ] || [ "${KEYMAP}" = viins ] \
- || [ -z "${KEYMAP}" ]; then
- printf %b '\e[5 q'
- fi
- }
- zle-line-init() zle -K viins; printf %b '\e[5 q'
- zle -N zle-keymap-select
- zle -N zle-line-init
- #- vim -#
- bindkey -v
- export KEYTIMEOUT=1
- __vi_bind_key() {
- bindkey -M viins "${1:?}" "${2:?}"
- bindkey -M vicmd "${1}" "${2}"
- }
- #- vim keys in tab complete menu -#
- bindkey -M menuselect 'h' vi-backward-char
- bindkey -M menuselect 'k' vi-up-line-or-history
- bindkey -M menuselect 'l' vi-forward-char
- bindkey -M menuselect 'j' vi-down-line-or-history
- # Include hidden files.
- _comp_options+=( globdots )
- # bindings
- __lfcd() {
- cd "$(command lf -print-last-dir "${@}" < "${TTY:-$(tty)}")"
- BUFFER=
- zle accept-line
- }
- __run_htop() { command htop < "${TTY:-$(tty)}"; zle reset-prompt; }
- zle -N __run_htop
- zle -N __lfcd
- __vi_bind_key '^[h' __run_htop
- __vi_bind_key '^o' __lfcd
- # Start typing + [Up-Arrow] - fuzzy find history forward
- autoload -U up-line-or-beginning-search
- zle -N up-line-or-beginning-search
- __vi_bind_key '^[[A' up-line-or-beginning-search
- # Start typing + [Down-Arrow] - fuzzy find history backward
- autoload -U down-line-or-beginning-search
- zle -N down-line-or-beginning-search
- __vi_bind_key '^[[B' down-line-or-beginning-search
- # [Shift-Tab] - move through the completion menu backwards
- if [ -n "${terminfo[kcbt]}" ]; then
- __vi_bind_key "${terminfo[kcbt]}" reverse-menu-complete
- fi
- # [Backspace] - delete backward
- bindkey -v '^?' backward-delete-char
- # [Delete] - delete forward
- if [[ -n "${terminfo[kdch1]}" ]]; then
- __vi_bind_key "${terminfo[kdch1]}" delete-char
- else
- __vi_bind_key '^[[3~' delete-char
- __vi_bind_key '^[3;5~' delete-char
- fi
- # [Ctrl-Delete] - delete whole forward-word
- __vi_bind_key '^[[3;5~' kill-word
- # [Ctrl-{RightArrow,f}] - move forward one word
- __vi_bind_key '^[[1;5C' forward-word
- __vi_bind_key '^[f' forward-word
- # [Ctrl-{LeftArrow,b}] - move backward one word
- __vi_bind_key '^[[1;5D' backward-word
- __vi_bind_key '^[b' backward-word
- # [Ctrl-w] - delete wprd
- __vi_bind_key '^[[w' kill-region
- # [Space] - don't do history expansion
- bindkey ' ' magic-space
- unset -f __vi_bind_key
|