Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Syntax highlighting in nano on Mac OS
# Last updated March, 2022 for Apple silicon Macs
# Install Homebrew if you don't already have it: https://brew.sh
# install nano from homebrew
brew install nano
# update your nanorc file
echo 'include "/opt/homebrew/Cellar/nano/*/share/nano/*.nanorc"' >> ~/.nanorc
# close and re-open your terminal and you'll have syntax highlighting
@lorthirk
Copy link

lorthirk commented May 31, 2021

+1 on @hacker1024 comment. single include with *.nanorc works for me as well.

@gilite
Copy link

gilite commented Jun 20, 2021

Thanks this worked! Is there any reason why the syntax highlighting only applies to nano, not sudo nano though?

@lorthirk
Copy link

lorthirk commented Jun 20, 2021

Thanks this worked! Is there any reason why the syntax highlighting only applies to nano, not sudo nano though?

In order to have it for sudo nano you have to edit the .nanorc for the root user

@gilite
Copy link

gilite commented Jun 20, 2021

@lorthirk That makes sense. Thanks for the help!

@romantech
Copy link

romantech commented Aug 22, 2021

Why does every file need to be listed? The following works for me:

brew install nano
echo 'include "/usr/local/share/nano/*.nanorc"' >> ~/.nanorc

This is nice! It works fine for me. Thank you!

@secfb
Copy link

secfb commented Oct 4, 2021

Mac OSX Big Sur
nano version:5.8

brew install nano 
echo 'include "/opt/homebrew/Cellar/nano/5.8/share/nano/*.nanorc"'>> ~/.nanorc

@robert-duplock-adg
Copy link

robert-duplock-adg commented Dec 13, 2021

Thanks @secfb (above), it worked beautifully on an M1 Mac running Monterery & zsh.
I ran:

brew install nano 
# Restart terminal
nano -V 
# Note the version number
echo 'include "/opt/homebrew/Cellar/nano/NANO_VERSION_NUMBER/share/nano/*.nanorc"'>> ~/.nanorc
# EG: echo 'include "/opt/homebrew/Cellar/nano/5.9/share/nano/*.nanorc"'>> ~/.nanorc

@tagplus5
Copy link

tagplus5 commented Dec 28, 2021

Brew creates symlink so you don't need set nano version number:
echo 'include "/usr/local/share/nano/*.nanorc"' >> ~/.nanorc

@bbuchheim
Copy link

bbuchheim commented Jan 12, 2022

or for Apple Silicon: echo 'include "/opt/homebrew/Cellar/nano/*/share/nano/*.nanorc"' >> ~/.nanorc

@BlakeGardner
Copy link
Author

BlakeGardner commented Mar 25, 2022

Brew creates symlink so you don't need set nano version number: echo 'include "/usr/local/share/nano/*.nanorc"' >> ~/.nanorc

Thanks @tagplus5, updated the gist for Apple Silicon

@phillco
Copy link

phillco commented Apr 7, 2022

or for Apple Silicon: echo 'include "/opt/homebrew/Cellar/nano//share/nano/.nanorc"' >> ~/.nanorc

Thanks! It's weird that you have to encode the wildcard for the version and you don't get a nice symlink like /usr/local/share/nano/ on Intel Macs. Hopefully there's only one version there at a time!

@eureka-cpu
Copy link

eureka-cpu commented Jun 19, 2022

Brew creates symlink so you don't need set nano version number: echo 'include "/usr/local/share/nano/*.nanorc"' >> ~/.nanorc

Thanks @tagplus5, updated the gist for Apple Silicon

This worked for me, brew install nano and then this command. Thanks! (on M1 MBP)

@leaf-ts
Copy link

leaf-ts commented Jul 7, 2022

for me what worked is

echo "include /opt/homebrew/Cellar/nano/6.3/share/nano/*.nanorc" >> ~/.nanorc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment