diff --git a/coreutils-colorls.csh b/coreutils-colorls.csh new file mode 100755 index 0000000..f2e9b12 --- /dev/null +++ b/coreutils-colorls.csh @@ -0,0 +1,32 @@ +# color-ls initialization +alias ll 'ls -l' +alias l. 'ls -d .*' + +set COLORS=/etc/DIR_COLORS +if ($?TERM) then + if ( -e "/etc/DIR_COLORS.$TERM" ) set COLORS="/etc/DIR_COLORS.$TERM" +endif +if ( -f ~/.dircolors ) set COLORS=~/.dircolors +if ($?TERM) then + if ( -f ~/.dircolors."$TERM" ) set COLORS=~/.dircolors."$TERM" +endif +if ( -f ~/.dir_colors ) set COLORS=~/.dir_colors +if ($?TERM) then + if ( -f ~/.dir_colors."$TERM" ) set COLORS=~/.dir_colors."$TERM" +endif + +if ( ! -e "$COLORS" ) exit + +eval `dircolors -c $COLORS` + +if ( "$LS_COLORS" == '' ) then + exit +endif + +set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS` +if ( "$color_none" == '' ) then +alias ll 'ls -l --color=tty' +alias l. 'ls -d .* --color=tty' +alias ls 'ls --color=tty' +endif +unset color_none diff --git a/coreutils-colorls.sh b/coreutils-colorls.sh new file mode 100755 index 0000000..ff9ac6a --- /dev/null +++ b/coreutils-colorls.sh @@ -0,0 +1,21 @@ +# color-ls initialization + +alias ll='ls -l' 2>/dev/null +alias l.='ls -d .*' 2>/dev/null + +COLORS=/etc/DIR_COLORS +[ -e "/etc/DIR_COLORS.$TERM" ] && COLORS="/etc/DIR_COLORS.$TERM" +[ -e "$HOME/.dircolors" ] && COLORS="$HOME/.dircolors" +[ -e "$HOME/.dircolors.$TERM" ] && COLORS="$HOME/.dircolors.$TERM" +[ -e "$HOME/.dir_colors" ] && COLORS="$HOME/.dir_colors" +[ -e "$HOME/.dir_colors.$TERM" ] && COLORS="$HOME/.dir_colors.$TERM" +[ -e "$COLORS" ] || return + +eval `dircolors --sh "$COLORS"` +[ -z "$LS_COLORS" ] && return + +if ! egrep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null ; then + alias ll='ls -l --color=tty' 2>/dev/null + alias l.='ls -d .* --color=tty' 2>/dev/null + alias ls='ls --color=tty' 2>/dev/null +fi