Sign in to follow this  
Followers 0

Alias for colorized `ls` for GNU and BSD ls

1 post in this topic

I recently committed my dotfiles to a git repo, and discovered that GNU ls and BSD ls use different switches to colorize output. Using the GNU switch with BSD ls results in ls not working until you unalias it! Here's a snippet from my .bashrc that takes care of it:

# alias `ls` for color modeif ls --color=auto / >/dev/null 2>&1thenalias ls='ls --color=auto' # GNU lselsealias ls='ls -G' # BSD lsfi

Basically, if the GNU switch works, use the GNU switch; otherwise, use the BSD switch.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0