From b79341b427fc40e3ee0976654cc706e6c71919fa Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 2 Dec 2016 12:50:17 -0500 Subject: [PATCH] Add a few keybindings --- .zshrc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.zshrc b/.zshrc index 66be8b1..06329d6 100644 --- a/.zshrc +++ b/.zshrc @@ -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