2006-02-08 09:20:05 +00:00
|
|
|
#
|
|
|
|
# Make ls use colors if we are on a system that supports this
|
|
|
|
#
|
|
|
|
|
2006-02-20 13:02:03 +00:00
|
|
|
if command ls --version 1>/dev/null 2>/dev/null
|
2006-02-08 09:20:05 +00:00
|
|
|
# This is GNU ls
|
2007-01-16 01:29:18 +00:00
|
|
|
function ls --description "List contents of directory"
|
2006-09-19 16:53:17 +00:00
|
|
|
set -l param --color=auto
|
|
|
|
if isatty 1
|
|
|
|
set param $param --indicator-style=classify
|
|
|
|
end
|
2006-10-04 23:55:30 +00:00
|
|
|
command ls $param $argv
|
2006-02-08 09:20:05 +00:00
|
|
|
end
|
2006-02-20 13:02:03 +00:00
|
|
|
|
2006-11-30 15:40:26 +00:00
|
|
|
if not set -q LS_COLORS
|
2014-07-10 07:26:58 +00:00
|
|
|
if type -q -f dircolors
|
2014-10-17 02:23:05 +00:00
|
|
|
set -l colorfile
|
|
|
|
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
|
|
|
|
if test -f $file
|
|
|
|
set colorfile $file
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2016-09-07 22:29:01 +00:00
|
|
|
set -gx LS_COLORS (dircolors -c $colorfile | string replace -r 'setenv LS_COLORS \'(.*)\'' '$1')
|
2006-11-30 15:40:26 +00:00
|
|
|
end
|
2006-02-20 13:02:03 +00:00
|
|
|
end
|
|
|
|
|
2006-02-08 09:20:05 +00:00
|
|
|
else
|
|
|
|
# BSD, OS X and a few more support colors through the -G switch instead
|
2009-02-01 22:24:10 +00:00
|
|
|
if command ls -G / 1>/dev/null 2>/dev/null
|
2007-01-16 01:29:18 +00:00
|
|
|
function ls --description "List contents of directory"
|
2006-02-08 09:20:05 +00:00
|
|
|
command ls -G $argv
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|