Add a few keybindings

This commit is contained in:
Adam Goldsmith 2016-12-02 12:50:17 -05:00
parent 4b73e35977
commit b79341b427

24
.zshrc
View File

@ -49,6 +49,30 @@ then
exec tmux new-session -A -s 'auto'
fi
# History Substring Search bindings
bindkey '^[[5~' history-substring-search-up
bindkey '^[[6~' history-substring-search-down
# 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