83 lines
1.6 KiB
Bash
83 lines
1.6 KiB
Bash
# vim: ft=zsh
|
|
|
|
KEYTIMEOUT=1
|
|
# Activate vim mode.
|
|
bindkey -v
|
|
|
|
bindkey -M visual 'i' vi-insert
|
|
bindkey -M visual 'a' vi-add-next
|
|
|
|
bindkey ' ' magic-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 '^U' kill-whole-line # C-u
|
|
bindkey -M vicmd '^U' kill-whole-line # C-u
|
|
|
|
bindkey -M viins '\e.' insert-last-word # M-.
|
|
|
|
bindkey '^[[Z' reverse-menu-complete # S-Tab
|
|
|
|
|
|
insert-sudo() {
|
|
local sudo_template="${SUDO:=sudo} "
|
|
local template_len="${#sudo_template}"
|
|
|
|
if [ -z "${LBUFFER}${RBUFFER}" ]; then
|
|
zle up-history
|
|
if [ ! "${LBUFFER::$template_len}" = "$sudo_template" ]; then
|
|
LBUFFER="${sudo_template}${LBUFFER}"
|
|
fi
|
|
return
|
|
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
|
|
|
|
bindkey '`' autosuggest-accept
|
|
bindkey '^?' backward-delete-char
|
|
bindkey '^W' backward-delete-word
|
|
|
|
bindkey -M vicmd '^H' backward-delete-char
|
|
|
|
|
|
gitstatusquiet() {
|
|
echo
|
|
git status
|
|
echo
|
|
zle reset-prompt
|
|
}
|
|
zle -N gitstatusquiet
|
|
bindkey "^L" gitstatusquiet
|
|
bindkey -M vicmd "^L" gitstatusquiet
|
|
|
|
|
|
popdquiet() {
|
|
popd &>/dev/null
|
|
zle reset-prompt
|
|
}
|
|
zle -N popdquiet
|
|
bindkey "^P" popdquiet
|
|
bindkey -M vicmd "^P" popdquiet
|
|
|
|
|
|
cddotdot() {
|
|
cd ..
|
|
zle reset-prompt
|
|
}
|
|
zle -N cddotdot
|
|
bindkey "^O" cddotdot
|
|
bindkey -M vicmd "^O" cddotdot |