aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/ls.sh
blob: 3ecaa5fd41136aaca2a943567d65361a70b43be5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Store ls(1)'s --help output in a variable
lshelp=$(ls --help 2>/dev/null)

# Define and store appropriate colors for ls(1) if applicable
case $lshelp in
    *--color*)
        if command -v dircolors >/dev/null 2>&1 ; then
            if [ -r "$HOME"/.dircolors ] ; then
                eval "$(dircolors --sh -- "$HOME"/.dircolors)"
            else
                eval "$(dircolors --sh)"
            fi
        fi
        ;;
esac

# We're done parsing ls(1)'s --help output now
unset -v lshelp