Skip to content

Instantly share code, notes, and snippets.

@raven-rock
Created May 19, 2017 17:09
Show Gist options
  • Save raven-rock/aabb10fefe35ce9b5d61dd282464a4c2 to your computer and use it in GitHub Desktop.
Save raven-rock/aabb10fefe35ce9b5d61dd282464a4c2 to your computer and use it in GitHub Desktop.
Smart ls color flag for your .zshrc/.bashrc that works on Mac or Linux
# Detect which `ls` flavor is in use (Mac or Linux)
if ls --color > /dev/null 2>&1; then
ls_color_flag="--color" # GNU/Linux
else
ls_color_flag="-G" # BSD/macOS
fi
# Always show color when interactive
alias ls="ls ${ls_color_flag}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment