bindkey '^[[1;3C' forward-word
bindkey '^[[1;3D' backward-word
-bindkey '^xp' history-beginning-search-backward
-bindkey '^xP' history-beginning-search-forward
-bindkey "\e[5~" history-beginning-search-backward #PageUp
-bindkey "\e[6~" history-beginning-search-forward #PageDown
+# Search backward in the history for a line beginning with the current
+# line up to the cursor and move the cursor to the end of the line then
+zle -N history-beginning-search-backward-end history-search-end
+zle -N history-beginning-search-forward-end history-search-end
+bindkey '^xp' history-beginning-search-backward-end
+bindkey '^xP' history-beginning-search-forward-end
+bindkey "\e[5~" history-beginning-search-backward-end # PageUp
+bindkey "\e[6~" history-beginning-search-forward-end # PageDown
+
# bindkey -s '^L' "|less\n" # ctrl-L pipes to less
# bindkey -s '^B' " &\n" # ctrl-B runs it in the background
-
# insert unicode character
# usage example: 'ctrl-x i' 00A7 'ctrl-x i' will give you an ยง
# See for example http://unicode.org/charts/ for unicode characters code
fi
}
+ _grmlinitd() {
+ local -a scripts
+ scripts=( /etc/init.d/*(x:t) )
+ _describe "service startup script" scripts
+ }
+
for i in Start Restart Stop Force-Reload Reload ; do
eval "$i() { __start_stop $i \"\$1\" \"\$2\" ; }"
+ compdef _grmlinitd $i
done
fi
mdiff() {
diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1"
}
+
+#f5# Create directory under cursor or the selected area
+# Press ctrl-xM to create the directory under the cursor or the selected area.
+# To select an area press ctrl-@ or ctrl-space and use the cursor.
+# Use case: you type "mv abc ~/testa/testb/testc/" and remember that the
+# directory does not exist yet -> press ctrl-XM and problem solved
+inplaceMkDirs() {
+ local PATHTOMKDIR
+ if ((REGION_ACTIVE==1)); then
+ local F=$MARK T=$CURSOR
+ if [[ $F -gt $T ]]; then
+ F=${CURSOR}
+ T=${MARK}
+ fi
+ # get marked area from buffer and eliminate whitespace
+ PATHTOMKDIR=${BUFFER[F+1,T]%%[[:space:]]##}
+ PATHTOMKDIR=${PATHTOMKDIR##[[:space:]]##}
+ else
+ local bufwords iword
+ bufwords=(${(z)LBUFFER})
+ iword=${#bufwords}
+ bufwords=(${(z)BUFFER})
+ PATHTOMKDIR="$bufwords[iword]"
+ fi
+ [[ -z "${PATHTOMKDIR}" ]] && return 1
+ if [[ -e "${PATHTOMKDIR}" ]]; then
+ zle -M " path already exists, doing nothing"
+ else
+ zle -M "$(mkdir -p -v "${PATHTOMKDIR}")"
+ zle end-of-line
+ fi
+}
+zle -N inplaceMkDirs && bindkey '^XM' inplaceMkDirs
+
#f5# Memory overview
memusage() {
ps aux | awk '{if (NR > 1) print $5; if (NR > 2) print "+"} END { print "p" }' | dc