I'm pretty used to how ls command shows pretty colorized output on most modern Linux distros, but somehow its default behaviour in MacOS is still plain white – no different colours.
I decided to look for command line option to change that, and sure enough – ls command in MacOS has -G option for colorizing output.
So, instead of running this:
$ ls /etc
you'll run this:
$ ls -G /etc
Check out the different it makes below!
Plain ls /etc in MacOS
Colorized ls -G /etc in MacOS
Make colorized alias for ls command
If you like this enough, I suggestt you make an alias for ls -G:
$ alias ls='ls -G'
what this does is you can run ls, but your bash shell will be recognizing it as alias name and running ls -G instead. Any additional command line options will work, of course:
Add ls alias to .bash_profile
To make this permanent, add ls alias to your .bash_profile:
$ echo "alias ls='ls -G'" >> $HOME/.bash_profile
What this will do is any new Terminal windows you open on your Mac will have the ls command alias preconfigured, so you'll always have the output colorized.
Leave a Reply