setopt interactivecomments # allow comments in interactive mode setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’ setopt nonomatch # hide error message if there is no match for the pattern setopt notify # report the status of background jobs immediately setopt numericglobsort # sort filenames numerically when it makes sense setopt promptsubst # enable command substitution in prompt setopt noflowcontrol # disable C-s mapping WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word # hide EOL sign ('%') PROMPT_EOL_MARK="" # Change cursor shape for different vi modes. zle-keymap-select() { if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then echo -ne '\e[2 q' elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then echo -ne '\e[5 q' fi } zle -N zle-keymap-select # Use beam shape cursor on startup. echo -ne '\e[5 q' _fix_cursor() { echo -ne '\e[5 q' } precmd_functions+=(_fix_cursor) # Set cursor style (DECSCUSR), VT520. # 0 -> blinking block. # 1 -> blinking block (default). # 2 -> steady block. # 3 -> blinking underline. # 4 -> steady underline. # 5 -> blinking bar, xterm. # 6 -> steady bar, xterm. # Activate vim mode. bindkey -v bindkey -M viins 'jf' vi-cmd-mode bindkey ' ' magic-space # history expansion on space bindkey '^K' up-line-or-history # C-k bindkey -M vicmd '^K' up-line-or-history # C-k bindkey '^J' down-line-or-history # C-j bindkey -M vicmd '^J' down-line-or-history # C-j bindkey -M vicmd '^U' kill-whole-line # C-u bindkey -M viins '^U' kill-whole-line # C-u bindkey -M viins '\e.' insert-last-word # M-. bindkey '^[[Z' reverse-menu-complete # S-Tab zle_highlight=('paste:bg=24,fg=15', 'region:bg=24,fg=15') # colors of visual select insert-sudo() { local sudo_template="${SUDO:=sudo} " local template_len="${#sudo_template}" if [ -z "${LBUFFER}${RBUFFER}" ]; then zle up-history fi if [ "${LBUFFER::$template_len}" = "$sudo_template" ]; then LBUFFER="${LBUFFER:$template_len}" else LBUFFER="${sudo_template}${LBUFFER}" fi } zle -N insert-sudo bindkey -M vicmd '^S' insert-sudo # C-s bindkey -M viins '^S' insert-sudo # C-s