Enable syntax coloring in Nano on Mac OS X

The basic version of Nano that comes with Mac OS X doesn’t support syntax coloring, and it’s pretty hard to find clear information online about how to enable it. Here is a quick guide on how to enable syntax coloring in Nano on Mac OS X.

Install Xcode’s command line tools

Before anything else, you’ll need to install the command line tools for Xcode. This is necessary to run the Brew commands we’ll use later. Open a terminal and type:


Install Homerew

You’ll also need Homebrew to install a new version of Nano that will make syntax coloring possible. Homebrew is a package manager for OS X, that makes it easy to install, update or remove programs. To install it, run the following command:

Install or upgrade Ruby

Then you’ll need to install the latest version of Ruby:


Or if you already have a version of Ruby installed (which is the case on OS X), you can just upgrade it:

Install or upgrade Nano

The last thing we’ll need to install is Nano itself. If you already have a version installed (which is very likely), run:


Otherwise, install it:


Enable syntax coloring

To enable syntax coloring, you have to modify the nanorc file, which is located in ~/.nanorc. The installation of Nano created nanorc files for each language in /usr/local/share/nano  (which, by the way, is a link to /usr/local/Cellar/nano/2.9.1/share/nano/).

If you want to enable syntax coloring only for some languages, let’s say C and Shell scripts, you can include those two nanorc files in ~/.nanorc. Run nano ~/.nanorc  to edit the file, and add the following lines to it:

Or if you want to enable syntax coloring for all languages available, add the following line:

Note that if the file ~/.nanorc doesn’t exist, it will be created.

And that’s it, now your files will be colored depending on which language they are using!

Be the first to comment

%d bloggers like this: