X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=196158dbe616b9dec80b4781367a9fb15c3cdfb5;hb=386c0c49de5531c1a0959a4968eaf265eca873dc;hp=beeba29b6d73e15aebfa85ee38c874dcc230fd5f;hpb=c9a74e732b7522129eda451691bbb5ad071c2cb2;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index beeba29..196158d 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)~~"$(&2; return 1;; +return 0;; + \?) bk -h >&2; return 1;; esac done shift "$((OPTIND-1))" if (( keep > 0 )); then - while (( $# > 0 )); do - if islinux || isfreebsd; then - cp $verbose -a "${1%/}" "${1%/}_$current_date" - else - cp $verbose -pR "${1%/}" "${1%/}_$current_date" - fi - (( result += $? )) - shift - done + if islinux || isfreebsd; then + for to_bk in "$@"; do + cp $verbose -a "${to_bk%/}" "${to_bk%/}_$current_date" + (( result += $? )) + done + else + for to_bk in "$@"; do + cp $verbose -pR "${to_bk%/}" "${to_bk%/}_$current_date" + (( result += $? )) + done + fi elif (( move > 0 )); then while (( $# > 0 )); do mv $verbose "${1%/}" "${1%/}_$current_date" @@ -3076,13 +3080,16 @@ EOT done elif (( clean > 0 )); then if (( $# > 0 )); then - while (( $# > 0 )); do - rm $verbose -rf "${1%/}"_[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 + for to_bk in "$@"; do + rm $verbose -rf "${to_bk%/}"_[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 (( result += $? )) - 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