X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=131a19b253711e19adb4cd5bb1018728ec95d8ea;hb=eb24dc890ae717df0753b32c3e04a033daf7f5ab;hp=6e70e5f521b3e03719c19a317b1d09499280542b;hpb=b3cec3054391bb54542d3a5a4998b626ad6cc322;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 6e70e5f..131a19b 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: Son Okt 15 23:20:08 CEST 2006 [mika] +# Latest change: Son Okt 29 17:49:13 CET 2006 [mika] ################################################################################ # This file is sourced only for interactive shells. It # should contain commands to set up aliases, functions, @@ -14,40 +14,39 @@ # {{{ 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 } + if isgrml ; then + isgrmlsmall() { + [[ ${${${(f)"$(' @@ -530,6 +549,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 +567,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: @@ -578,6 +599,17 @@ grmlcomp() { # zstyle ':completion:*' completer _complete _correct _approximate # zstyle ':completion:*' expand prefix suffix +# automatic rehash? Credits go to Frank Terbeck +# function my_accept () { +# local buf +# [[ -z ${BUFFER} ]] && zle accept-line && return +# buf=( ${(z)BUFFER} ) +# [[ -z ${commands[${buf[1]}]} ]] && rehash +# zle accept-line +# } +# zle -N my_accept +# bindkey "^M" my_accept + # command for process lists, the local web server details and host completion hosts=(`hostname` grml.org) zstyle '*' hosts $hosts @@ -668,16 +700,34 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done } manzsh() { /usr/bin/man zshall | vim -c "se ft=man| se hlsearch" +/"$1" - ; } +# manzsh() { /usr/bin/man zshall | most +/"$1" ; } # manzsh() { man zshall | $MYLESS -p $1 ; } -# manzsh() { /usr/bin/man zshall | most +/"$1" ; } # use "dchange " to view Debian's changelog of the package: - dchange() { most /usr/share/doc/${1}/changelog.Debian.gz ; } + dchange() { + if [ -r /usr/share/doc/${1}/changelog.Debian.gz ] ; then + most /usr/share/doc/${1}/changelog.Debian.gz + else + if [ -r /usr/share/doc/${1}/changelog.gz ] ; then + most /usr/share/doc/${1}/changelog.gz + else + echo "No changelog for package $1 found, sorry." + return 1 + fi + fi + } _dchange() { _files -W /usr/share/doc -/ } compdef _dchange dchange # use "uchange " to view upstream's changelog of the package: - uchange() { most /usr/share/doc/${1}/changelog.gz ; } + uchange() { + if [ -r /usr/share/doc/${1}/changelog.gz ] ; then + most /usr/share/doc/${1}/changelog.gz + else + echo "No changelog for package $1 found, sorry." + return 1 + fi + } _uchange() { _files -W /usr/share/doc -/ } compdef _uchange uchange @@ -696,13 +746,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