typeset -ga ls_options
typeset -ga grep_options
+
+# Colors on GNU ls(1)
if ls --color=auto / >/dev/null 2>&1; then
ls_options+=( --color=auto )
+# Colors on FreeBSD and OSX ls(1)
elif ls -G / >/dev/null 2>&1; then
ls_options+=( -G )
fi
ls_options+=( -v )
fi
+# Color on GNU and FreeBSD grep(1)
if grep --color=auto -q "a" <<< "a" >/dev/null 2>&1; then
grep_options+=( --color=auto )
fi