How to Enable Syntax Highlighting in Mac Terminal
How To Make Your Mac Terminal Have Syntax Highlighting like Linux
Mac has a pretty bad wrap amongst more tech-savvy people. However, Mac is absolutely an Operating System that can be used by power-users. Mac is based on UNIX, and because of that, practically anything that can be done on UNIX can be done on Mac. However, one thing Mac is bad at is having a good Terminal. The Mac Terminal starts you off with a plain white theme.
However, there are plenty of different themes you can use with your Mac terminal if you go into the terminal preferences, with COMMAND+,. I prefer to use theme Pro. Pro is a good Terminal because it’s see-through, has a black background, and doesn’t make things look more complicated than they actually are like the green and black Homebrew theme. It is Pro that I used to configure the Mac terminal to have syntax highlighting, and I recommend you use it too.
What I Did
The way I set this up is pretty simple. I started by setting Pro as the default Terminal theme. Then, I used a slightly modified version of the Ubuntu bashrc, and used it as the bash_profile, which is Mac’s version of bashrc, and replaced that. That gave me the cool colors that you get with Ubuntu and some other Linux distros.
Alright, here’s the tutorial on it. This is a fairly easy tutorial, but it assumes you already know at least a little bit about how to use the command line. You probably wouldn’t be trying to do this tutorial unless you wanted to improve your command line, which would be useless if you have never used it. So, without further ado, here’s the tutorial.
Setting the Terminal Theme (Optional)
To start off with, you will want to set up the Terminal theme. Start by opening up your terminal, and pressing COMMAND+,. This will open up the Terminal preferences. In the image below, these are the settings I use in the General section. This is really the only section you need to modify. You don’t have to do this, but I recommend doing it.
Setting Up Color Coding
Now, you will want to download a file. This file is a slightly modified version of the Ubuntu bashrc. Make sure that when you download it, you put the file in your Downloads section.
Now that you are done with that, you will want to open up your terminal and paste and execute the following command:
mv ~/Downloads/bash_profile ~/.bash_profile && chmod +x .bash_profile
And now, all you have to do is restart the terminal, and you’re all good. It’s colorful and beautiful as ever!