X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=1b8648d64a5e65c66fcd8066edda0b937ad15114;hp=beeba29b6d73e15aebfa85ee38c874dcc230fd5f;hb=8945506c355c0e705ebe8a8f035a419d9459ca5f;hpb=c9a74e732b7522129eda451691bbb5ad071c2cb2 diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index beeba29..1b8648d 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -198,6 +198,10 @@ isopenbsd(){ [[ $GRML_OSTYPE == "OpenBSD" ]] } +issolaris(){ + [[ $GRML_OSTYPE == "SunOS" ]] +} + #f1# are we running within an utf environment? isutfenv() { case "$LANG $CHARSET $LANGUAGE" in @@ -354,12 +358,12 @@ ZSH_NO_DEFAULT_LOCALE=${ZSH_NO_DEFAULT_LOCALE:-0} typeset -ga ls_options typeset -ga grep_options if ls --color=auto / >/dev/null 2>&1; then - ls_options=( --color=auto ) + ls_options+=( --color=auto ) elif ls -G / >/dev/null 2>&1; then - ls_options=( -G ) + ls_options+=( -G ) fi if grep --color=auto -q "a" <<< "a" >/dev/null 2>&1; then - grep_options=( --color=auto ) + grep_options+=( --color=auto ) fi # utility functions @@ -414,23 +418,22 @@ salias() { emulate -L zsh local only=0 ; local multi=0 local key val - while [[ $1 == -* ]] ; do - case $1 in - (-o) only=1 ;; - (-a) multi=1 ;; - (--) shift ; break ;; - (-h) - printf 'usage: salias [-h|-o|-a] \n' + while getopts ":hao" opt; do + case $opt in + o) only=1 ;; + a) multi=1 ;; + h) + printf 'usage: salias [-hoa] \n' printf ' -h shows this help text.\n' printf ' -a replace '\'' ; '\'' sequences with '\'' ; sudo '\''.\n' printf ' be careful using this option.\n' printf ' -o only sets an alias if a preceding sudo would be needed.\n' return 0 ;; - (*) printf "unkown option: '%s'\n" "$1" ; return 1 ;; + *) salias -h >&2; return 1 ;; esac - shift done + shift "$((OPTIND-1))" if (( ${#argv} > 1 )) ; then printf 'Too many arguments %s\n' "${#argv}" @@ -768,7 +771,7 @@ grmlcomp() { [[ -r ~/.ssh/known_hosts ]] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() [[ -r /etc/hosts ]] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$( 0 )); then while (( $# > 0 )); do - if islinux || isfreebsd; then + if islinux || isfreebsd; then cp $verbose -a "${1%/}" "${1%/}_$current_date" else cp $verbose -pR "${1%/}" "${1%/}_$current_date" @@ -3082,7 +3086,11 @@ EOT shift done else - rm $verbose -rf *_[0-9](#c4,)-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3])(:[0-5][0-9])(#c2)Z + if (( all > 0 )); then + rm $verbose -rf *_[0-9](#c4,)-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3])(:[0-5][0-9])(#c2)Z(D) + else + rm $verbose -rf *_[0-9](#c4,)-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3])(:[0-5][0-9])(#c2)Z + fi (( result += $? )) fi fi