Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nano syntax highlighting in Mac OS X 10.7 (Lion)?

How to enable syntax highlighting for nano in Mac OS X 10.7 (Lion)?

According to what I found so far on Google is that it has got to do with /.nanorc file. I have no idea how to get it or make it?

When I try to find nano in my terminal this is what I get:

Notra:~ Sukhvir$ whereis nano /usr/bin/nano 

According to what I found on Internet this is the file I need to edit:

~/.nanorc 

But how do I get to it/how to open it/if I don't have it then how to make it?

I am a bit new to programming folks, so step-by-step instructions will be highly appreciated.

I need it for C mainly.

According to what I found online, I have to paste this into the .nanorc file:

include "/usr/share/nano/nanorc.nanorc" include "/usr/share/nano/c.nanorc" 

However this will not work because there is no such directory as /usr/share/nano.

I also just did ls /usr/share/ and according to the results there is no nano in that directory. Is this a Mac OS X 10.7 (Lion) issue or an issue on my Mac?

like image 390
sukhvir Avatar asked Mar 10 '12 00:03

sukhvir


People also ask

How do I enable syntax highlighting in nano?

In order to enable syntax highlighting for nano in Cygwin, you will need to create ~/. nanorc , which is the file that nano looks for when loading syntax highlighting.

Can nano do syntax highlighting?

GNU nano (or nano) is a text editor which aims to introduce a simple interface and intuitive command options to console based text editing. nano supports features including colorized syntax highlighting, DOS/Mac file type conversions, spellchecking and UTF-8 encoding.

Where is Nanorc in Mac?

nanorc files are installed in /opt/local/share/nano (including a python. nanorc ).


1 Answers

On Mac, Homebrew (brew) will allow you to easily upgrade nano to a newer version than the one that came with Mac OSX.

Install brew, then install a new version of nano from the Terminal.

brew install nano 

Installing this way includes the /usr/local/share/nano folder containing the default syntax highlight files. See also the extra subdirectory.

To enable all default syntaxes, add a wildcard include to your ~/.nanorc.

include "/usr/local/share/nano/*.nanorc" 

For Apple Silicon (M1), the path is under /opt/homebrew/:

include "/opt/homebrew/share/nano/*.nanorc" 
like image 194
Joel Purra Avatar answered Sep 28 '22 08:09

Joel Purra