X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=5466b635d7dcde4b3ee1dc57cc738469a59ab3c4;hb=73d7a9a13106115c65b57734e1fca59b23152c3f;hp=528c3ee5bc801860fc0cb005a27e289c4e790d57;hpb=a0cb586db00052329d1f3517dce39700ec0b0575;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 528c3ee..5466b63 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: Don Nov 30 16:15:06 CET 2006 [mika] +# Latest change: Son Dez 17 13:52:04 CET 2006 [mika] ################################################################################ # This file is sourced only for interactive shells. It # should contain commands to set up aliases, functions, @@ -47,6 +47,14 @@ isgrmlsmall() { return 1 } fi + # are we running within an utf environment? + isutfenv() { + case "$LANG $CHARSET $LANGUAGE" in + *utf*) return 0 ;; + *) return 1 ;; + esac + } + # check for user, if not running as root set $SUDO to sudo (( EUID != 0 )) && SUDO='sudo' || SUDO='' @@ -231,8 +239,8 @@ fi autoload run-help # use via 'esc-h' # completion system - if autoload -U compinit && [ -f "/usr/share/zsh/$ZSH_VERSION/functions/Completion/compinit" ] && compinit 2>/dev/null ; then - compinit + if autoload -U compinit && compinit 2>/dev/null ; then + compinit 2>/dev/null || print 'Notice: no compinit available :(' else print 'Notice: no compinit available :(' function zstyle { } @@ -242,7 +250,7 @@ fi is4 && autoload -U zed # use ZLE editor to edit a file or function is4 && for mod in complist deltochar mathfunc ; do - zmodload -i zsh/${mod} + zmodload -i zsh/${mod} 2>/dev/null || print "Notice: no ${mod} available :(" done # autoload zsh modules when they are referenced @@ -306,7 +314,8 @@ fi # }}} # {{{ set some important options - umask 022 + # umask 022 + umask 002 # history: setopt append_history # append history list to the history file (important for multiple parallel zsh sessions!) @@ -363,6 +372,18 @@ fi isgrmlcd && SAVEHIST=1000 || SAVEHIST=10000 # useful for setopt append_history # }}} +# dirstack handling {{{ + DIRSTACKSIZE=20 + if [[ -f ~/.zdirs ]] && [[ ${#dirstack[*]} -eq 0 ]]; then + dirstack=( ${(uf)"$(< ~/.zdirs)"} ) + # "cd -" won't work after login by just setting $OLDPWD, so + cd $dirstack[0] && cd $OLDPWD + fi + chpwd() { + builtin dirs -pl >! ~/.zdirs + } +# }}} + # {{{ display battery status on right side of prompt via running 'BATTERY=1 zsh' if [ -n "$BATTERY" ] ; then if [ -x =acpi ] ; then @@ -387,8 +408,8 @@ fi # precmd () { setopt promptsubst; [[ -o interactive ]] && jobs -l; - is4 && ! [[ -n "$NOPRECMD" ]] && precmd () { - (( NOPRECMD > 0 )) && return 0 + is4 && [[ -z $NOPRECMD ]] && precmd () { + [[ -n $NOPRECMD ]] && return 0 # just use DONTSETRPROMPT=1 to be able to overwrite RPROMPT if [[ -z ${DONTSETRPROMPT} ]] ; then if [ -n "$BATTERY" ] ; then @@ -410,8 +431,8 @@ fi # chpwd () => a function which is executed whenever the directory is changed # preexec() => a function running before every command - is4 && ! [[ -n "$NOPRECMD" ]] && preexec () { - (( NOPRECMD > 0 )) && return 0 + is4 && [[ -z $NOPRECMD ]] && preexec () { + [[ -n $NOPRECMD ]] && return 0 # set hostname if not running on host with name 'grml' local HOSTNAME=$(hostname) if [[ "$HOSTNAME" != grml ]] ; then @@ -535,7 +556,11 @@ ${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< %# " # truecrypt; use e.g. via 'truec /dev/ice' /mnt/ice' or 'truec -i' if [ -x /usr/sbin/truecrypt ] ; then - alias truec='truecrypt --mount-options "rw,sync,dirsync,users,uid=1000,gid=users,umask=077" ' + if isutfenv ; then + alias truec='truecrypt --mount-options "rw,sync,dirsync,users,uid=1000,gid=users,umask=077,utf8" ' + else + alias truec='truecrypt --mount-options "rw,sync,dirsync,users,uid=1000,gid=users,umask=077" ' + fi fi zsh-help(){print "$bg[white]$fg[black] @@ -546,7 +571,7 @@ Main configuration of zsh happens in /etc/zsh/zshrc (global) and /etc/skel/.zshrc which is copied to \$HOME/.zshrc once. The files are part of the package grml-etc-core, if you want to use them on a non-grml-system just get the tar.gz from -http://grml.org/repos/ or get the files from the mercurial +http://deb.grml.org/ or get the files from the mercurial repository: http://hg.grml.org/grml-etc-core/raw-file/tip/etc/skel/.zshrc @@ -667,8 +692,6 @@ grmlcomp() { zstyle ':completion:*:history-words' menu yes # activate menu zstyle ':completion:*:history-words' remove-all-dups yes # ignore duplicate entries zstyle ':completion:*:history-words' stop yes # - zstyle ':completion:*:*:linda:*' file-patterns '*.deb' # complete debian packages for command 'linda' - 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 '' @@ -820,9 +843,15 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." # shell functions {{{ 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 ; } + + # fast manual access + if type -p qma &>/dev/null ; then + manzsh() { qma zshall "$1" } + else + 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 ; } + fi # use "dchange " to view Debian's changelog of the package: dchange() { @@ -830,10 +859,10 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." 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 + most /usr/share/doc/${1}/changelog.gz else - echo "No changelog for package $1 found, sorry." - return 1 + echo "No changelog for package $1 found, sorry." + return 1 fi fi } @@ -914,7 +943,7 @@ If you want to use xinit anyway please call \"/usr/bin/xinit\"." } alias help-zshglob=H-Glob - type -p fma &>/dev/null && alias ?='fma zshall' + type -p qma &>/dev/null && alias ?='qma zshall' # grep for running process, like: 'any vim' any() {