aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/ls.bash
blob: 4b647163be630b43f6ab9f4e080d02a525589ed9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Store whether we have colors in a variable
declare -i colors
colors=$( {
    tput Co || tput colors
} 2>/dev/null )

# Use LSOPTS to add some useful options to ls(1) calls if applicable; we use a
# function wrapper to do this
declare -a LSOPTS
if [[ -n $LS_COLORS ]] && ((colors >= 8)) ; then
    LSOPTS[${#LSOPTS[@]}]='--color=auto'
fi

# Done, unset helper var
unset -v colors

# Define function proper
ls() {
    command ls "${LSOPTS[@]}" "$@"
}