From b427cd182394b14ac1c696b252b00114f62e6b77 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 24 Oct 2018 19:27:51 +0200 Subject: [PATCH] ls.fish: Use gdircolors if available See #5278. --- share/functions/ls.fish | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/functions/ls.fish b/share/functions/ls.fish index 79c20237e..9023b74e4 100644 --- a/share/functions/ls.fish +++ b/share/functions/ls.fish @@ -12,7 +12,15 @@ if command ls --version >/dev/null 2>/dev/null end if not set -q LS_COLORS - if command -sq dircolors + set -l dircolors + for d in gdircolors dircolors + if command -sq $d + set dircolors $d + break + end + end + + if set -q dircolors[1] set -l colorfile for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS if test -f $file @@ -22,7 +30,7 @@ if command ls --version >/dev/null 2>/dev/null end # Here we rely on the legacy behavior of `dircolors -c` producing output suitable for # csh in order to extract just the data we're interested in. - set -gx LS_COLORS (dircolors -c $colorfile | string split ' ')[3] + set -gx LS_COLORS ($dircolors -c $colorfile | string split ' ')[3] # The value should always be quoted but be conservative and check first. if string match -qr '^([\'"]).*\1$' -- $LS_COLORS set LS_COLORS (string match -r '^.(.*).$' $LS_COLORS)[2]