mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS
https://mths.be/dotfiles
MIT License
30.01k stars 8.74k forks source link

Check for `ls` flavor in `.aliases` is no longer correct #1063

Open djotto opened 2 months ago

djotto commented 2 months ago
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
    colorflag="--color"
    export LS_COLORS=[...]
else # macOS `ls`
    colorflag="-G"
    export LSCOLORS=[...]
fi

At some point, the macOS version of ls started understanding the --color flag (I'm on 14.4.1)

I propose this instead, but I can't test it against earlier versions of macOS:

if ls --help > /dev/null 2>&1; then
   echo "GNU ls";
else
   echo "MacOS ls";
fi;

PR to follow.