mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-16 23:22:45 +08:00
ls
No Longer Sets LS_COLORS
This commit is contained in:
parent
3f7fdd5693
commit
5cf36bf3f8
|
@ -15,6 +15,8 @@ We have tried to keep these to a minimum, but in some cases it is unavoidable.
|
|||
- ``functions --handlers`` will now list handlers in a different order.
|
||||
Now it is definition order, first to last, where before it was last to first.
|
||||
This was never specifically defined, and we recommend not relying on a specific order (:issue:`9944`).
|
||||
- ``LS_COLORS`` is no longer set automatically by ``ls`` (:issue:`10080`). Users
|
||||
that set ``.dircolors`` should manually import it using other means.
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
|
|
|
@ -1,22 +1,3 @@
|
|||
function __fish_set_lscolors --description 'Set $LS_COLORS if possible'
|
||||
if ! set -qx LS_COLORS && set -l cmd (command -s {g,}dircolors)[1]
|
||||
set -l colorfile
|
||||
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
|
||||
if test -f $file
|
||||
set colorfile $file
|
||||
break
|
||||
end
|
||||
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 ($cmd -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]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ls --description "List contents of directory"
|
||||
# Make ls use colors and show indicators if we are on a system that supports that feature and writing to stdout.
|
||||
#
|
||||
|
@ -34,10 +15,10 @@ function ls --description "List contents of directory"
|
|||
# Since that one's quite different, don't use it.
|
||||
if command -sq colorls
|
||||
and command colorls -GF >/dev/null 2>/dev/null
|
||||
set -g __fish_ls_color_opt -GF
|
||||
set -g __fish_ls_color_opt -G
|
||||
set -g __fish_ls_command colorls
|
||||
else
|
||||
for opt in --color=auto -G --color -F
|
||||
for opt in --color=auto -G --color
|
||||
if command ls $opt / >/dev/null 2>/dev/null
|
||||
set -g __fish_ls_color_opt $opt
|
||||
break
|
||||
|
@ -46,9 +27,6 @@ function ls --description "List contents of directory"
|
|||
end
|
||||
end
|
||||
|
||||
# Set the colors to the default via `dircolors` if none is given.
|
||||
__fish_set_lscolors
|
||||
|
||||
set -l opt
|
||||
isatty stdout
|
||||
and set -a opt -F
|
||||
|
|
Loading…
Reference in New Issue
Block a user