add support for INCLUDE in colorls scripts (#818069)

This commit is contained in:
Ondrej Oprala 2013-03-11 16:00:59 +01:00
parent 76ade64f4b
commit 1ad51b6276
3 changed files with 22 additions and 4 deletions

View File

@ -10,6 +10,8 @@ endif
alias ll 'ls -l'
alias l. 'ls -d .*'
set COLORS=/etc/DIR_COLORS
set TMP="`mktemp .colorlsXXX`"
if ($?TERM) then
if ( -e "/etc/DIR_COLORS.$TERM" ) then
set COLORS="/etc/DIR_COLORS.$TERM"
@ -26,10 +28,14 @@ if ($?TERM) then
if ( -f ~/.dircolors."$TERM" ) set COLORS=~/.dircolors."$TERM"
if ( -f ~/.dir_colors."$TERM" ) set COLORS=~/.dir_colors."$TERM"
endif
set INCLUDE="`cat "$COLORS" | grep '^INCLUDE' | cut -d ' ' -f2-`"
if ( ! -e "$COLORS" ) exit
eval "`dircolors -c $COLORS`"
if ( "$INCLUDE" != '' ) cat "$INCLUDE" > $TMP
cat "$COLORS" | grep -v '^INCLUDE' >> $TMP
eval "`dircolors -c $TMP`"
if ( "$LS_COLORS" == '' ) exit
set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS`
@ -38,6 +44,7 @@ if ( "$color_none" != '' ) then
exit
endif
unset color_none
rm -f $TMP
finish:
alias ll 'ls -l --color=auto'

View File

@ -10,11 +10,15 @@ if [ -z "$USER_LS_COLORS" ]; then
# Skip the rest for noninteractive shells.
[ -z "$PS1" ] && return
INCLUDE=
COLORS=
TMP="`mktemp .colorlsXXX`"
for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \
"$HOME/.dir_colors" "$HOME/.dircolors"; do
[ -e "$colors" ] && COLORS="$colors" && break
[ -e "$colors" ] && COLORS="$colors" && \
INCLUDE="`cat "$COLORS" | grep '^INCLUDE' | cut -d ' ' -f2-`" && \
break
done
[ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \
@ -30,9 +34,13 @@ if [ -z "$USER_LS_COLORS" ]; then
# Existence of $COLORS already checked above.
[ -n "$COLORS" ] || return
eval "`dircolors --sh "$COLORS" 2>/dev/null`"
[ -e "$INCLUDE" ] && cat "$INCLUDE" > $TMP
cat "$COLORS" | grep -v '^INCLUDE' >> $TMP
eval "`dircolors --sh $TMP 2>/dev/null`"
[ -z "$LS_COLORS" ] && return
grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
rm -f $TMP
fi
alias ll='ls -l --color=auto' 2>/dev/null

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.21
Release: 8%{?dist}
Release: 9%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -375,6 +375,9 @@ fi
%{_sbindir}/chroot
%changelog
* Mon Mar 11 2013 Ondrej Oprala <ooprala@redhat.com> 8.21-9
- add support for INCLUDE in colorls scripts (#818069)
* Mon Mar 04 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-8
- fix factor on AArch64 (M.Salter, #917735)