Auto display color difference when use ls
This commit is contained in:
parent
e739bb4ed1
commit
e7a2878b0f
152
backport-config-color-alias-for-ls.patch
Normal file
152
backport-config-color-alias-for-ls.patch
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
From 69331283c881e3a6cb49f3aeacd699b3d79183fc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tim Waugh <twaugh@fedoraproject.org>
|
||||||
|
Date: Feb 14 2007 12:33:54 +0000
|
||||||
|
Subject: [PATCH] config color alias for ls
|
||||||
|
|
||||||
|
---
|
||||||
|
build-aux/coreutils-colorls.csh | 68 +++++++++++++++++++++++++++++++++
|
||||||
|
build-aux/coreutils-colorls.sh | 57 +++++++++++++++++++++++++++
|
||||||
|
2 files changed, 125 insertions(+)
|
||||||
|
create mode 100755 build-aux/coreutils-colorls.csh
|
||||||
|
create mode 100755 build-aux/coreutils-colorls.sh
|
||||||
|
|
||||||
|
diff --git a/build-aux/coreutils-colorls.csh b/build-aux/coreutils-colorls.csh
|
||||||
|
new file mode 100755
|
||||||
|
index 0000000..f631762
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/build-aux/coreutils-colorls.csh
|
||||||
|
@@ -0,0 +1,68 @@
|
||||||
|
+# skip everything for non-interactive shells
|
||||||
|
+if (! $?prompt) exit
|
||||||
|
+
|
||||||
|
+# color-ls initialization
|
||||||
|
+if ( $?USER_LS_COLORS ) then
|
||||||
|
+ if ( "$USER_LS_COLORS" != "" ) then
|
||||||
|
+ #when USER_LS_COLORS defined do not override user
|
||||||
|
+ #specified LS_COLORS and use them
|
||||||
|
+ goto finish
|
||||||
|
+ endif
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+alias ll 'ls -l'
|
||||||
|
+alias l. 'ls -d .*'
|
||||||
|
+set COLORS=/etc/DIR_COLORS
|
||||||
|
+
|
||||||
|
+if ($?TERM) then
|
||||||
|
+ if ( -e "/etc/DIR_COLORS.256color" ) then
|
||||||
|
+ if ( "`/usr/bin/tput colors`" == "256" ) then
|
||||||
|
+ set COLORS=/etc/DIR_COLORS.256color
|
||||||
|
+ endif
|
||||||
|
+ endif
|
||||||
|
+ if ( -e "/etc/DIR_COLORS.$TERM" ) then
|
||||||
|
+ set COLORS="/etc/DIR_COLORS.$TERM"
|
||||||
|
+ endif
|
||||||
|
+endif
|
||||||
|
+if ( -f ~/.dircolors ) set COLORS=~/.dircolors
|
||||||
|
+if ( -f ~/.dir_colors ) set COLORS=~/.dir_colors
|
||||||
|
+if ($?TERM) then
|
||||||
|
+ if ( -f ~/.dircolors."$TERM" ) set COLORS=~/.dircolors."$TERM"
|
||||||
|
+ if ( -f ~/.dir_colors."$TERM" ) set COLORS=~/.dir_colors."$TERM"
|
||||||
|
+endif
|
||||||
|
+set INCLUDE="`/usr/bin/cat "$COLORS" | /usr/bin/grep '^INCLUDE' | /usr/bin/cut -d ' ' -f2-`"
|
||||||
|
+
|
||||||
|
+if ( ! -e "$COLORS" ) exit
|
||||||
|
+
|
||||||
|
+set _tmp="`/usr/bin/mktemp .colorlsXXX -q --tmpdir=/tmp`"
|
||||||
|
+#if mktemp fails, exit when include was active, otherwise use $COLORS file
|
||||||
|
+if ( "$_tmp" == '' ) then
|
||||||
|
+ if ( "$INCLUDE" == '' ) then
|
||||||
|
+ eval "`/usr/bin/dircolors -c $COLORS`"
|
||||||
|
+ endif
|
||||||
|
+ goto cleanup
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+if ( "$INCLUDE" != '' ) /usr/bin/cat "$INCLUDE" >> $_tmp
|
||||||
|
+/usr/bin/grep -v '^INCLUDE' "$COLORS" >> $_tmp
|
||||||
|
+
|
||||||
|
+eval "`/usr/bin/dircolors -c $_tmp`"
|
||||||
|
+
|
||||||
|
+/usr/bin/rm -f $_tmp
|
||||||
|
+
|
||||||
|
+if ( "$LS_COLORS" == '' ) exit
|
||||||
|
+cleanup:
|
||||||
|
+set color_none=`/usr/bin/sed -n '/^COLOR.*none/Ip' < $COLORS`
|
||||||
|
+if ( "$color_none" != '' ) then
|
||||||
|
+ unset color_none
|
||||||
|
+ exit
|
||||||
|
+endif
|
||||||
|
+unset color_none
|
||||||
|
+unset _tmp
|
||||||
|
+unset INCLUDE
|
||||||
|
+unset COLORS
|
||||||
|
+
|
||||||
|
+finish:
|
||||||
|
+alias ll 'ls -l --color=auto'
|
||||||
|
+alias l. 'ls -d .* --color=auto'
|
||||||
|
+alias ls 'ls --color=auto'
|
||||||
|
diff --git a/build-aux/coreutils-colorls.sh b/build-aux/coreutils-colorls.sh
|
||||||
|
new file mode 100755
|
||||||
|
index 0000000..a4ba227
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/build-aux/coreutils-colorls.sh
|
||||||
|
@@ -0,0 +1,57 @@
|
||||||
|
+# color-ls initialization
|
||||||
|
+
|
||||||
|
+# Skip all for noninteractive shells.
|
||||||
|
+[ ! -t 0 ] && return
|
||||||
|
+
|
||||||
|
+#when USER_LS_COLORS defined do not override user LS_COLORS, but use them.
|
||||||
|
+if [ -z "$USER_LS_COLORS" ]; then
|
||||||
|
+
|
||||||
|
+ alias ll='ls -l' 2>/dev/null
|
||||||
|
+ alias l.='ls -d .*' 2>/dev/null
|
||||||
|
+
|
||||||
|
+ INCLUDE=
|
||||||
|
+ COLORS=
|
||||||
|
+
|
||||||
|
+ for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \
|
||||||
|
+ "$HOME/.dir_colors" "$HOME/.dircolors"; do
|
||||||
|
+ [ -e "$colors" ] && COLORS="$colors" && \
|
||||||
|
+ INCLUDE="`/usr/bin/cat "$COLORS" | /usr/bin/grep '^INCLUDE' | /usr/bin/cut -d ' ' -f2-`" && \
|
||||||
|
+ break
|
||||||
|
+ done
|
||||||
|
+
|
||||||
|
+ [ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.$TERM" ] && \
|
||||||
|
+ COLORS="/etc/DIR_COLORS.$TERM"
|
||||||
|
+
|
||||||
|
+ [ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \
|
||||||
|
+ [ "x`/usr/bin/tty -s && /usr/bin/tput colors 2>/dev/null`" = "x256" ] && \
|
||||||
|
+ COLORS="/etc/DIR_COLORS.256color"
|
||||||
|
+
|
||||||
|
+ [ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS" ] && \
|
||||||
|
+ COLORS="/etc/DIR_COLORS"
|
||||||
|
+
|
||||||
|
+ # Existence of $COLORS already checked above.
|
||||||
|
+ [ -n "$COLORS" ] || return
|
||||||
|
+
|
||||||
|
+ if [ -e "$INCLUDE" ];
|
||||||
|
+ then
|
||||||
|
+ TMP="`/usr/bin/mktemp .colorlsXXX -q --tmpdir=/tmp`"
|
||||||
|
+ [ -z "$TMP" ] && return
|
||||||
|
+
|
||||||
|
+ /usr/bin/cat "$INCLUDE" >> $TMP
|
||||||
|
+ /usr/bin/grep -v '^INCLUDE' "$COLORS" >> $TMP
|
||||||
|
+
|
||||||
|
+ eval "`/usr/bin/dircolors --sh $TMP 2>/dev/null`"
|
||||||
|
+ /usr/bin/rm -f $TMP
|
||||||
|
+ else
|
||||||
|
+ eval "`/usr/bin/dircolors --sh $COLORS 2>/dev/null`"
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
+ [ -z "$LS_COLORS" ] && return
|
||||||
|
+ /usr/bin/grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+unset TMP COLORS INCLUDE
|
||||||
|
+
|
||||||
|
+alias ll='ls -l --color=auto' 2>/dev/null
|
||||||
|
+alias l.='ls -d .* --color=auto' 2>/dev/null
|
||||||
|
+alias ls='ls --color=auto' 2>/dev/null
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: coreutils
|
Name: coreutils
|
||||||
Version: 9.0
|
Version: 9.0
|
||||||
Release: 3
|
Release: 4
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Summary: A set of basic GNU tools commonly used in shell scripts
|
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||||
Url: https://www.gnu.org/software/coreutils/
|
Url: https://www.gnu.org/software/coreutils/
|
||||||
@ -26,6 +26,7 @@ Patch10: backport-dd-do-not-access-uninitialized.patch
|
|||||||
Patch11: backport-df-fix-memory-leak.patch
|
Patch11: backport-df-fix-memory-leak.patch
|
||||||
Patch12: backport-ls-avoid-triggering-automounts.patch
|
Patch12: backport-ls-avoid-triggering-automounts.patch
|
||||||
Patch13: backport-stat-only-automount-with-cached-never.patch
|
Patch13: backport-stat-only-automount-with-cached-never.patch
|
||||||
|
Patch14: backport-config-color-alias-for-ls.patch
|
||||||
|
|
||||||
Conflicts: filesystem < 3
|
Conflicts: filesystem < 3
|
||||||
# To avoid clobbering installs
|
# To avoid clobbering installs
|
||||||
@ -64,7 +65,7 @@ the old GNU fileutils, sh-utils, and textutils packages.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -N
|
%autosetup -N
|
||||||
|
tee DIR_COLORS{,.256color,.lightbgcolor} <src/dircolors.hin >/dev/null
|
||||||
%autopatch -p1
|
%autopatch -p1
|
||||||
|
|
||||||
(echo ">>> Fixing permissions on tests") 2>/dev/null
|
(echo ">>> Fixing permissions on tests") 2>/dev/null
|
||||||
@ -108,6 +109,11 @@ mv $RPM_BUILD_ROOT/{%_bindir,%_sbindir}/chroot
|
|||||||
# Add the %%lang(xyz) ownership for the LC_TIME dirs as well...
|
# Add the %%lang(xyz) ownership for the LC_TIME dirs as well...
|
||||||
grep LC_TIME %name.lang | cut -d'/' -f1-6 | sed -e 's/) /) %%dir /g' >>%name.lang
|
grep LC_TIME %name.lang | cut -d'/' -f1-6 | sed -e 's/) /) %%dir /g' >>%name.lang
|
||||||
|
|
||||||
|
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
|
||||||
|
install -p -c -m644 DIR_COLORS{,.256color,.lightbgcolor} $RPM_BUILD_ROOT%{_sysconfdir}
|
||||||
|
install -p -c -m644 build-aux/coreutils-colorls.sh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/colorls.sh
|
||||||
|
install -p -c -m644 build-aux/coreutils-colorls.csh $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/colorls.csh
|
||||||
|
|
||||||
%check
|
%check
|
||||||
pushd separate
|
pushd separate
|
||||||
make check VERBOSE=yes
|
make check VERBOSE=yes
|
||||||
@ -133,6 +139,8 @@ fi
|
|||||||
%doc ABOUT-NLS NEWS README THANKS TODO
|
%doc ABOUT-NLS NEWS README THANKS TODO
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%exclude %{_infodir}/dir
|
%exclude %{_infodir}/dir
|
||||||
|
%config(noreplace) %{_sysconfdir}/profile.d/*
|
||||||
|
%config(noreplace) %{_sysconfdir}/DIR_COLORS*
|
||||||
|
|
||||||
%package_help
|
%package_help
|
||||||
%files help
|
%files help
|
||||||
@ -140,6 +148,9 @@ fi
|
|||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jul 7 2022 zoulin <zoulin13@h-partners.com> - 9.0-4
|
||||||
|
- Auto display color difference when use ls
|
||||||
|
|
||||||
* Tue Mar 29 2022 panxiaohe <panxh.life@foxmail.com> - 9.0-3
|
* Tue Mar 29 2022 panxiaohe <panxh.life@foxmail.com> - 9.0-3
|
||||||
- dd: improve integer overflow checking
|
- dd: improve integer overflow checking
|
||||||
- dd: do not access uninitialized
|
- dd: do not access uninitialized
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user