From cf79d2cdb811b689605ca5757508ce4a0bf2f127 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 23 Jul 2012 15:45:47 +0200 Subject: .aliases: Optimize the way we detect the `ls` flavor Follow-up to 4169a34df1783b6b0727a527b867cefecaa069b5. Thanks to @janmoesen! --- .aliases | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.aliases b/.aliases index 01d6181..dbcafeb 100644 --- a/.aliases +++ b/.aliases @@ -19,11 +19,10 @@ alias o="open" alias oo="open ." # Detect which `ls` flavor is in use -tmp="$(ls --color 2>&1 > /dev/null | grep "illegal option")" -if [ '' == "$tmp" ]; then # GNU `ls` - colorflag="--color" -else # OS X `ls` +if ls --color 2> /dev/null | grep -q 'invalid option'; then # OS X `ls` colorflag="-G" +else # GNU `ls` + colorflag="--color" fi # List all files colorized in long format -- cgit v1.2.3