mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS

Home Page:https://mths.be/dotfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

djotto opened this issue · comments

# 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.