Help enabling nano syntax highlighting

So what do I have to add to get it to work for sudo then too?

Do as @keybreak mentioned here.

You haven’t used sudo all this time for test don’t you…? :rofl:

That would explain a lot, since again - it requires separate config at
/root/.nanorc

include /usr/share/nano/*.nanorc
include /usr/share/nano-syntax-highlighting/*.nanorc
1 Like

So do I do:

touch ~/root/.nanorc
nano ~/root/.nanorc

Add:

include /usr/share/nano/*.nanorc
include /usr/share/nano-syntax-highlighting/*.nanorc

Save that and should give sudo colors? Or is there another way I should be doing that?

Pretty much, but you can actually do just:

sudo nano /root/.nanorc 

paste all that
save it

P.S. Actually where the hell have you found ~ in my post about root? :rofl:
It’s just /root

I was browsing over this while experimenting, I know it’s not Arch per se, but I think that’s where we got the “~” from fyi:

When I run sudo nano ~/root/.nanorc and try to save I get an error. :joy:

( gets rid of ~ … )

sudo nano /root/.nanorc

Add:

include /usr/share/nano/*.nanorc
include /usr/share/nano-syntax-highlighting/*.nanorc

Save, and run a sudo file known to display some color syntax and…voila!? :joy: :joy:

Screenshot from 2022-05-28 16-35-36

But one thing worth noting is the red error message at the bottom saying “mistakes in include /usr/share/nano-syntax-highlighting/*.nanorc”

Should I just get ride of “include /usr/share/nano-syntax-highlighting/*.nanorc” because otherwise I think I’ll be seeing that red error message in every nano window :sweat_smile:

As you wish :man_shrugging: you’ll loose some extended syntax highlighting though…wonder what’s that error all about.

Yes, nano tries to load each one of the .nanorc files in the directory and responds with an error for every line that invokes an unsupported value. That’s why there are several errors per .nanorc file (which are one .nanorc file per language syntax definition). So basically several languages were not supported in the version I was using in Arch, nano 2.9.1-1.

However, several others were. I simply deleted the unsupported syntax (.nanorc) files and stopped receiving the errors.

It had nothing to do with the default.nanorc file. Sorry if that wasn’t clear.

I was mostly just curious if they were supported in a different version of nano. What version have you tested these definition files with?

Thanks! Hope you have a nice day, too :slight_smile:

This is an error I get for example:

[scott@EndeavourOS ~]$ sudo nano /etc/nanorc
Error in /usr/share/nano-syntax-highlighting/nanorc.nanorc on line 26: Color 'normal' takes no prefix

PLus the red error shows up if it’s sudo or not. This is starting to become very troublesome :sweat_smile:

1 Like

I have a similar error. I renamed nanorc.nanorc to nanorc.nanorc_old and copied /usr/share/nano/nanorc.nanorc to /usr/share/nano-syntax-highlighting/nanorc.nanorc to get rid of the error and I don’t notice any difference in the highlighting.

We’re at v6.3 though… :rofl:
It was 2017…

Will Echo them all without using asterix
Needs to replace install path with the path to the rc files indeed

Less universal, in case there will be updates and new languages added, if we’re talking iso skel :wink:

Yea bloated in case of lines of text :wink:

1 Like

Just a quick recap to condense the solution that worked for me:

Enable nano colors without sudo, create nanorc file in Home directory:

nano ~/.nanorc

Added only this (nano-syntax-highlighting was giving too many errors):

include /usr/share/nano/*.nanorc

Save and exit.

Enable nano colors with sudo:

sudo nano /root/.nanorc 

Added the same line as above:

include /usr/share/nano/*.nanorc

Save and exit. Now “some” nano colors are enabled and working with and without sudo. The nano-syntax-highlighting package just honestly seems like more effort than it’s worth to figure out, so I think I’ll just stick with this for now.

1 Like

I will check to replicate this…
As it is shipped with i3 and xfce4

1 Like

You should not use sudo in home dir though, just

nano ~/.nanorc

sudo should be used only when it’s necessary, otherwise permissions / owner of file will be messed for your home user

3 Likes

Perhaps check the ownership of ~/.nanorc?

ls -al ~/.nanorc

2 Likes
[scott@EndeavourOS ~]$ ls -al ~/.nanorc
-rw-r--r-- 1 scott scott 33 May 28 16:57 /home/scott/.nanorc

Edit: FYI, love seeing this community come together to figure stuff out :purple_heart: :enos:

2 Likes

Yes, having wrong permissions causes issues in these configurations.

3 Likes

/usr/share/nano-syntax-highlighting/nanorc.nanorc

Error in /usr/share/nano-syntax-highlighting/nanorc.nanorc on line 26: Color 'normal' takes no prefix

for this will be fixed on next update what will come n late 2025 i would bet :wink:

There is a git version in AUR:
https://aur.archlinux.org/packages/nano-syntax-highlighting-git
what have the same error indeed as it is still not merged all together…

So this is strange in a way as … nanorc.nanorc is the one for highlighting… nanorc files … should get solved and indeed changing brightnormal to normal as it does not allow a prefix will solve the error in red…
And there is also exclude what excludes files you do not want:
exclude /usr/share/nano-syntax-highlighting/nanorc.nanorc per example in your .nanorc…

other than this it is fully working for me :
nano-higlight-gnome
nano-higlight-tilix
nano-higlight-xfce4

2 Likes