X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=87c9bda1abc1a79a378ff33f1dfe2e3ce67e3bb2;hp=2d89da236c22bee388bb374d3bbab0e09c8a69e4;hb=a8546c960706ce0b930e981e358abcfb2d6e6bd3;hpb=764b20402a8a268b1f31cdad82c5fd65ed2cf192 diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 2d89da2..87c9bda 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -332,6 +332,18 @@ BATTERY=${BATTERY:-0} GRMLSMALL_SPECIFIC=${GRMLSMALL_SPECIFIC:-1} ZSH_NO_DEFAULT_LOCALE=${ZSH_NO_DEFAULT_LOCALE:-0} +typeset -ga ls_options +typeset -ga grep_options +if ls --help 2> /dev/null | grep -q GNU; then + ls_options=( --color=auto ) +elif [[ $OSTYPE == freebsd* ]]; then + ls_options=( -G ) +fi +if grep --help 2> /dev/null | grep -q GNU || \ + [[ $OSTYPE == freebsd* ]]; then + grep_options=( --color=auto ) +fi + # utility functions # this function checks if a command exists and returns either true # or false. This avoids using 'which' and 'whence', which will @@ -886,7 +898,7 @@ abk=( '....' '../../..' 'BG' '& exit' 'C' '| wc -l' - 'G' '|& grep --color=auto ' + 'G' '|& grep '${grep_options:+"${grep_options[*]} "} 'H' '| head' 'Hl' ' --help |& less -r' #d (Display help in pager) 'L' '| less' @@ -1460,19 +1472,17 @@ if check_com -c screen ; then fi # do we have GNU ls with color-support? -if ls --help 2>/dev/null | grep -- --color= >/dev/null \ - && [[ "$TERM" != dumb ]] -then +if [[ "$TERM" != dumb ]]; then #a1# execute \kbd{@a@}:\quad ls with colors - alias ls='ls -b -CF --color=auto' + alias ls='ls -b -CF '${ls_options:+"${ls_options[*]} "} #a1# execute \kbd{@a@}:\quad list all files, with colors - alias la='ls -la --color=auto' + alias la='ls -la '${ls_options:+"${ls_options[*]} "} #a1# long colored list, without dotfiles (@a@) - alias ll='ls -l --color=auto' + alias ll='ls -l '${ls_options:+"${ls_options[*]} "} #a1# long colored list, human readable sizes (@a@) - alias lh='ls -hAl --color=auto' + alias lh='ls -hAl '${ls_options:+"${ls_options[*]} "} #a1# List files, append qualifier to filenames \\&\quad(\kbd{/} for directories, \kbd{@} for symlinks ...) - alias l='ls -lF --color=auto' + alias l='ls -lF '${ls_options:+"${ls_options[*]} "} else alias ls='ls -b -CF' alias la='ls -la' @@ -2164,7 +2174,7 @@ any() { echo "any - grep for process(es) by keyword" >&2 echo "Usage: any " >&2 ; return 1 else - ps xauwww | grep -i --color=auto "[${1[1]}]${1[2,-1]}" + ps xauwww | grep -i "${grep_options[@]}" "[${1[1]}]${1[2,-1]}" fi } @@ -2258,29 +2268,29 @@ alias j='jobs -l' #a2# Execute \kbd{ls -lSrah} alias dir="ls -lSrah" #a2# Only show dot-directories -alias lad='ls -d .*(/)' # only show dot-directories +alias lad='ls -d .*(/)' #a2# Only show dot-files -alias lsa='ls -a .*(.)' # only show dot-files +alias lsa='ls -a .*(.)' #a2# Only files with setgid/setuid/sticky flag -alias lss='ls -l *(s,S,t)' # only files with setgid/setuid/sticky flag -#a2# Only show 1st ten symlinks -alias lsl='ls -l *(@)' # only symlinks +alias lss='ls -l *(s,S,t)' +#a2# Only show symlinks +alias lsl='ls -l *(@)' #a2# Display only executables -alias lsx='ls -l *(*)' # only executables +alias lsx='ls -l *(*)' #a2# Display world-{readable,writable,executable} files -alias lsw='ls -ld *(R,W,X.^ND/)' # world-{readable,writable,executable} files +alias lsw='ls -ld *(R,W,X.^ND/)' #a2# Display the ten biggest files -alias lsbig="ls -flh *(.OL[1,10])" # display the biggest files +alias lsbig="ls -flh *(.OL[1,10])" #a2# Only show directories -alias lsd='ls -d *(/)' # only show directories +alias lsd='ls -d *(/)' #a2# Only show empty directories -alias lse='ls -d *(/^F)' # only show empty directories +alias lse='ls -d *(/^F)' #a2# Display the ten newest files -alias lsnew="ls -rtlh *(D.om[1,10])" # display the newest files +alias lsnew="ls -rtlh *(D.om[1,10])" #a2# Display the ten oldest files -alias lsold="ls -rtlh *(D.Om[1,10])" # display the oldest files +alias lsold="ls -rtlh *(D.Om[1,10])" #a2# Display the ten smallest files -alias lssmall="ls -Srl *(.oL[1,10])" # display the smallest files +alias lssmall="ls -Srl *(.oL[1,10])" #a2# Display the ten newest directories and ten newest .directories alias lsnewdir="ls -rthdl *(/om[1,10]) .*(D/om[1,10])" #a2# Display the ten oldest directories and ten oldest .directories @@ -2294,9 +2304,6 @@ alias rmcdir='cd ..; rmdir $OLDPWD || cd $OLDPWD' alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"' alias insecscp='scp -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"' -# simple webserver -check_com -c python && alias http="python -m SimpleHTTPServer" - # work around non utf8 capable software in utf environment via $LANG and luit if check_com isutfenv && check_com luit ; then if check_com -c mrxvt ; then @@ -2409,7 +2416,7 @@ check_com new || alias new=modified # use colors when GNU grep with color-support #a2# Execute \kbd{grep -{}-color=auto} -(grep --help 2>/dev/null |grep -- --color) >/dev/null && alias grep='grep --color=auto' +(( $#grep_options > 0 )) && alias grep='grep '${grep_options:+"${grep_options[*]} "} # Translate DE<=>EN # 'translate' looks up fot a word in a file with language-to-language