X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=99642aa59dc2525bd179ecd7447f634904ffad82;hb=538b20715841b392eb9b8f7a410546e78de57afa;hp=f383424b85b869460b4534dfc139146872883671;hpb=4c89b303d62900127dd383375a5cf559b012bb3e;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index f383424..99642aa 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -3,7 +3,7 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Sam Okt 21 16:20:30 CEST 2006 [mika] +# Latest change: Mit Okt 25 23:44:27 CEST 2006 [mika] ################################################################################ # This file is sourced only for interactive shells. It # should contain commands to set up aliases, functions, @@ -14,38 +14,29 @@ # {{{ check for version/system # check for versions (compatibility reasons) - is4(){ - if [[ $ZSH_VERSION == 4.* ]]; then - return 0 - else - return 1 - fi - } - -# current release - is42(){ - if [[ $ZSH_VERSION == 4.<2->* ]]; then - return 0 - else - return 1 - fi - } + if autoload is-at-least && is-at-least ; then + is4() { is-at-least 4 } + is42() { is-at-least 4.2 } + else + is4(){ + [[ $ZSH_VERSION == 4.* ]] && return 0 + return 1 + } + is42(){ + [[ $ZSH_VERSION == 4.<2->* ]] && return 0 + return 1 + } + fi # grml specific stuff isgrml(){ - if [ -f /etc/grml_version ] ; then - return 0 - else - return 1 - fi + [ -f /etc/grml_version ] && return 0 + return 1 } isgrmlcd(){ - if [ -f /etc/grml_cd ] ; then - return 0 - else - return 1 - fi + [ -f /etc/grml_cd ] && return 0 + return 1 } # check for user, if not running as root set $SUDO to sudo @@ -63,9 +54,9 @@ # }}} # {{{ set some variables - [[ -z "$EDITOR" ]] && export EDITOR='vim' - [[ -z "$SHELL" ]] && export SHELL='/bin/zsh' - [[ -z "$MAIL" ]] && export MAIL="/var/mail/$USER" + export EDITOR=${EDITOR:-vim} + export SHELL=${SHELL:-/bin/zsh} + export MAIL=${MAIL:-/var/mail/$USER} [[ -f ~/.terminfo/m/mostlike ]] && MYLESS='LESS=C TERMINFO=~/.terminfo TERM=mostlike less' || MYLESS='less' [[ -x /usr/bin/dircolors ]] && eval `dircolors -b` @@ -151,14 +142,19 @@ fi fi is4 && autoload -U zed # use ZLE editor to edit a file or function - is4 && zmodload -i zsh/complist - is4 && zmodload -i zsh/deltochar - is4 && zmodload -i zsh/mathfunc + is4 && \ + for mod in complist deltochar mathfunc ; do + zmodload -i zsh/${mod} + done # autoload zsh modules when they are referenced - is4 && zmodload -a zsh/stat stat - is4 && zmodload -a zsh/zpty zpty - is4 && zmodload -a zsh/zprof zprof - is4 && zmodload -ap zsh/mapfile mapfile + is4 && \ + for opt mod in a stat \ + a zpty \ + a zprof \ + ap mapfile ; do + zmodload -${opt} zsh/${mod} ${mod} + done + unset opt mod is4 && autoload -U insert-files && \ zle -N insert-files && \ @@ -172,6 +168,9 @@ fi zle -N edit-command-line && \ bindkey '\ee' edit-command-line +## menu selection: pick item but stay in the menu (press esc-return) + is4 && bindkey -M menuselect '\e^M' accept-and-menu-complete + # press "ctrl-e d" to insert the actual date in the form yyyy-mm-dd _bkdate() { BUFFER="$BUFFER$(date '+%F')"; CURSOR=$#BUFFER; } bindkey '\C-ed' _bkdate @@ -330,13 +329,24 @@ fi esac } +# set colors + if autoload colors && colors ; then + BLUE="%{${fg[blue]}%}" + RED="%{${fg_bold[red]}%}" + GREEN="%{${fg[green]}%}" + CYAN="%{${fg[cyan]}%}" + WHITE="%{${fg[white]}%}" + NO_COLOUR="%{${reset_color}%}" + else + BLUE="%{%}" + RED="%{%}" + GREEN="%{%}" + CYAN="%{%}" + WHITE="%{%}" + NO_COLOUR="%{%}" + fi + EXITCODE="%(?..%?%1v )" - local BLUE="%{%}" - local RED="%{%}" - local GREEN="%{%}" - local CYAN="%{%}" - local WHITE="%{%}" - local NO_COLOUR="%{%}" PS2='`%_> ' # secondary prompt, printed when the shell needs more information to complete a command. PS3='?# ' # selection prompt used within a select loop. PS4='+%N:%i:%_> ' # the execution trace prompt (setopt xtrace). default: '+%N:%i>' @@ -530,6 +540,7 @@ grmlcomp() { zstyle ':completion:*:*:lintian:*' file-patterns '*.deb' # complete debian packages for command 'lintian' zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # match uppercase from lowercase zstyle ':completion:*:matches' group 'yes' # separate matches into groups + zstyle ':completion:*' group-name '' if [[ -z "$NOMENU" ]] ; then zstyle ':completion:*' menu select=5 # if there are more than 5 options allow selecting from a menu else @@ -547,8 +558,9 @@ grmlcomp() { zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*' # Ignore completion functions for commands you don't have: # complete manual by their section - zstyle ':completion:*:manuals' separate-sections true - zstyle ':completion:*:man:*' menu yes select + zstyle ':completion:*:manuals' separate-sections true + zstyle ':completion:*:manuals.*' insert-sections true + zstyle ':completion:*:man:*' menu yes select ## correction # run rehash on completion so new installed program are found automatically: @@ -706,6 +718,7 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." echo "No changelog for package $1 found, sorry." return 1 fi + } _uchange() { _files -W /usr/share/doc -/ } compdef _uchange uchange @@ -724,13 +737,16 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." # use it e.g. via 'Restart apache2' if [ -d /etc/init.d ] ; then for i in Start Restart Stop Reload ; do - eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} $2 ; }" + eval "$i() { $SUDO /etc/init.d/\$1 ${i:l} \$2 ; }" done # now the completion for this: compctl -g "$(echo /etc/init.d/*(:t))" Start Restart Stop Reload fi # }}} +# make sure our environment is clean regarding colors + for color in BLUE RED GREEN CYAN WHITE ; unset $color + # source another config file if present {{{ if [ -r /etc/zsh/zshrc.local ]; then source /etc/zsh/zshrc.local