aboutsummaryrefslogtreecommitdiff
path: root/dot.zshrc.from_grml
diff options
context:
space:
mode:
authorThomas Schneider <thosch97@gmail.com>2015-02-15 12:31:57 +0100
committerThomas Schneider <thosch97@gmail.com>2015-02-15 12:31:57 +0100
commita2e767e164cb1e8859a30078c89df25e1f611f38 (patch)
tree22471055227f2915b3cf244f104eafb821c9671f /dot.zshrc.from_grml
Initial import of own zshrc files
They depend on grml’s zshrc. Signed-off-by: Thomas Schneider <thosch97@gmail.com>
Diffstat (limited to 'dot.zshrc.from_grml')
-rw-r--r--dot.zshrc.from_grml74
1 files changed, 74 insertions, 0 deletions
diff --git a/dot.zshrc.from_grml b/dot.zshrc.from_grml
new file mode 100644
index 0000000..d9050ca
--- /dev/null
+++ b/dot.zshrc.from_grml
@@ -0,0 +1,74 @@
+## Settings for umask
+if (( EUID == 0 )); then
+ umask 002
+else
+ umask 022
+fi
+
+# Virtualenv support
+
+function virtual_env_prompt () {
+ REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
+}
+grml_theme_add_token virtual-env -f virtual_env_prompt '%F{magenta}' '%f'
+zstyle ':prompt:grml:left:setup' items rc virtual-env change-root user at host path vcs percent
+
+## ZLE tweaks ##
+
+## use the vi navigation keys (hjkl) besides cursor keys in menu completion
+bindkey -M menuselect 'h' vi-backward-char # left
+bindkey -M menuselect 'k' vi-up-line-or-history # up
+bindkey -M menuselect 'l' vi-forward-char # right
+bindkey -M menuselect 'j' vi-down-line-or-history # bottom
+
+## set command prediction from history, see 'man 1 zshcontrib'
+is4 && zrcautoload predict-on && \
+zle -N predict-on && \
+zle -N predict-off && \
+bindkey "^X^Z" predict-on && \
+bindkey "^Z" predict-off
+
+# just type '...' to get '../..'
+rationalise-dot() {
+local MATCH
+if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
+ LBUFFER+=/
+ zle self-insert
+ zle self-insert
+else
+ zle self-insert
+fi
+}
+zle -N rationalise-dot
+bindkey . rationalise-dot
+## without this, typing a . aborts incremental history search
+bindkey -M isearch . self-insert
+
+## add `|' to output redirections in the history
+setopt histallowclobber
+
+## alert me if something failed
+setopt printexitvalue
+
+## Allow comments even in interactive shells
+setopt interactivecomments
+
+## get top 10 shell commands:
+alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
+
+## miscellaneous code ##
+
+## Use a default width of 80 for manpages for more convenient reading
+export MANWIDTH=${MANWIDTH:-80}
+
+## List all occurrences of programm in current PATH
+plap() {
+ emulate -L zsh
+ if [[ $# = 0 ]] ; then
+ echo "Usage: $0 program"
+ echo "Example: $0 zsh"
+ echo "Lists all occurrences of program in the current PATH."
+ else
+ ls -l ${^path}/*$1*(*N)
+ fi
+} \ No newline at end of file