Enable syntax highlighting for nano on macOS Catalina

Add RSS feed to Reader and sync to Readwise.

The default version of nano that is installed on a mac most likely does not support syntax highlighting. To check your version run:

nano --version

You will need to upgrade it using a version from Homebrew. If you don’t have Homebrew, then you can install it easily.

Think of Homebrew like a command line based AppStore.

To install Homebrew, run the following command from Terminal

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"Code language: JavaScript (javascript)

More info about installing Homebrew at their site.

Now that you have Homebrew installed, you can get the upgraded version of nano by running:

brew install nano

After installation, close & reopen your Terminal. Now if you run nano --version you should see that your version of nano is upgraded. This newer version of nano supports colors and syntax highlighting.

You now need to set the highlight colors for various languages. Fortunately, there are many users who’ve created these color rules and you can quickly download & use one of these “rulesets”.

You can download one such ruleset created by scopatz at Github using this command:

curl https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh | shCode language: Bash (bash)

Run this from your user’s root folder to download and set the rules for the user. The command will download the rules for various languages and save it to a folder called .nano. It will also create the .nanorc which refers to this list of rules in .nano folder.

Close & reopen Terminal again to ensure that nano now uses these rules.

Open an HTML file, for example, and you’ll notice that the HTML tags are now color-coded.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *