Add some custom functions to input module

* ... -> ../.. expansion
 * sudo prefix
 * bind ^H to backward-kill-word
This commit is contained in:
Adam Goldsmith 2016-02-15 11:24:14 -05:00
parent f988d80d78
commit a8667fdb91

View File

@ -95,3 +95,26 @@ zle-line-finish() {
} }
zle -N zle-line-init zle -N zle-line-init
zle -N zle-line-finish zle -N zle-line-finish
# Expands ... to ../..
function expand-dot-to-parent-directory-path {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+='/..'
else
LBUFFER+='.'
fi
}
zle -N expand-dot-to-parent-directory-path
bindkey -M emacs "." expand-dot-to-parent-directory-path
# Inserts 'sudo ' at the beginning of the line.
function prepend-sudo() {
if [[ "$BUFFER" != su(do|)\ * ]]; then
BUFFER="sudo $BUFFER"
(( CURSOR += 5 ))
fi
}
zle -N prepend-sudo
bindkey "^X^S" prepend-sudo
bindkey '^H' backward-kill-word