1

I'm trying to set my color syntax highlighting in nano, but it doesn't work as expected.

  1. One system everything works. This is an Fedora 21 laptop.

  2. Two systems everything I've tried except man something works. This is an Fedora 21 desktop and an Fedora 21 vm in VirtualBox.

  3. One system only one file I've tried works(opening nanorc itself gives highlighting). This is an Debian Wheezy desktop.

If I do man emacs it only works as expected on one system. I also have syntax highlighting for many other types of files, I thought the only thing I needed to set this up was to have .nanorc located in the users home directory so nano could find it. This is very confusing.

I've tried to look for differences in bash_profile, /etc/profile, bashrc but nothing stands out and maybe that's irrelevant. I've looked at the permissions. I've started an new terminal and restarted the system.

Here is a piece from my .nanorc file:

#####################################################################

## Manpages
##include "/usr/share/nano/man.nanorc"

## Here is an example for manpages.
##
syntax "man" "\.[1-9]x?$"
color green "\.(S|T)H.*$"
color brightgreen "\.(S|T)H" "\.TP"
color brightred "\.(BR?|I[PR]?).*$"
color brightblue "\.(BR?|I[PR]?|PP)"
color brightwhite "\\f[BIPR]"
color yellow "\.(br|DS|RS|RE|PD)"

#####################################################################

Questions:

Why is the same .nanorc file not working the same on four Linux systems(Fedora 21 is working, two Fedora 21 not working and Debian Wheezy not working at all). What am I missing?

What are the steps to set a custom .nanorc file to be used by nano and be sure it's not in some kind of conflict or something?

--------------------------------------------

Here is the full nanorc file on pastebin.com.

  • 1
    Having a similar problem. I have the includes uncommented. I even downloaded new syntax highlighting files from the GitHub project github.com/tech4david/nano-highlight. In Nano, my .nanorc file has colors, but none of my Bash scripts do. I've even tried specifying the syntax with --syntax=. I noticed that nano is compiled with --enable-colors so that's not the issue. – Andy Forceno Mar 30 '16 at 10:43
0

Uncommenting the include paths should do it.

eg. ##include "/usr/share/nano/c.nanorc" has comments in front of include ".... Remove the comments and open a c/c++ file; the text should be highlighted. Do this for all the other includes you want.

  • 1
    This is probably not the case/problem as this is from the same nanorc file on all systems, it works perfectly on one of them, and it also has those lines commented out. – somethingSomething Apr 21 '15 at 18:36
0

I since found that there is a bug in nano < 2.7.4-1

nano: /etc/nanorc is ignored, if ~/.nanorc exists

Latest from the bug report:

I just made the dist-upgrade to Debian 9.0, which included an update of package nano to version 2.7.4-1 and the problem vanished, the bug is solved in 2.7.4-1.

The bug report: bug

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.