On my VM, I have syntax highlighting in nano for perl, python, and bash.
I did this by adding
include /usr/share/nano/python.nanorc
to my ~/.nanorc file
However, I just bought a new Macbook pro, and /usr/share/nano does not exist at that location, despite that vim, emacs, etc. are in that location ...
find . -name "nano" returns ./usr/bin/nano, but this is only the executable (I think) and not the folder that I need containing the *.nanorc files.
Has anyone done this on 10.9.5 ?
If you're using Apple's nano, you can copy .nanorc
files from any source to somewhere in your homedir, such as ~/.nano
.
The nano-highlight repository seems to be an attempt to collect all of the best syntax highlighting .nanorc
s in one place. Following the directions there may be the simplest solution.
If you install MacPorts' nano, some .nanorc
files are installed in /opt/local/share/nano
(including a python.nanorc
).
Most of the nano-highlight .nanorc
s appear to be compatible with both Apple and MacPorts nano, with the exception that Apple nano (which is older) doesn't understand the bash.nanorc
. Either nano will segfault if you try to include all of them; I'm not sure if that bug is triggered by a particular .nanorc
, but I suspect it's triggered by including too many (regardless of which ones).
UPDATE: The .nanorc
files in the nano-highlight repository are only partly compatible with Apple nano. Some of the colors will not be used, but no error will be given. According to this comment on the bash.nanorc
bug, the problem is a result of differences between the BSD and POSIX regular expression syntaxes, and can be fixed by modifying all of the .nanorc
files with this command:
sed -i -e 's|\<|[[:<:]]|g;s|\>|[[:>:]]|g' /path/to/nanorc/files/*
MacPorts nano is not affected (it uses a regular expression engine installed by MacPorts).