aboutsummaryrefslogblamecommitdiff
path: root/bash/bashrc.d/ls.bash
blob: 0fd246febb1e7b1288a9a1783b78b303e518ba5d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                              
  
 


                        

                        
                                  

 
# 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[@]}" "$@"
}