mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
parent
afc82ff23e
commit
b427cd1823
1 changed files with 10 additions and 2 deletions
|
@ -12,7 +12,15 @@ if command ls --version >/dev/null 2>/dev/null
|
||||||
end
|
end
|
||||||
|
|
||||||
if not set -q LS_COLORS
|
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
|
set -l colorfile
|
||||||
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
|
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
|
||||||
if test -f $file
|
if test -f $file
|
||||||
|
@ -22,7 +30,7 @@ if command ls --version >/dev/null 2>/dev/null
|
||||||
end
|
end
|
||||||
# Here we rely on the legacy behavior of `dircolors -c` producing output suitable for
|
# 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.
|
# 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.
|
# The value should always be quoted but be conservative and check first.
|
||||||
if string match -qr '^([\'"]).*\1$' -- $LS_COLORS
|
if string match -qr '^([\'"]).*\1$' -- $LS_COLORS
|
||||||
set LS_COLORS (string match -r '^.(.*).$' $LS_COLORS)[2]
|
set LS_COLORS (string match -r '^.(.*).$' $LS_COLORS)[2]
|
||||||
|
|
Loading…
Reference in a new issue