Last active
August 18, 2025 18:20
-
Star
(203)
You must be signed in to star a gist -
Fork
(30)
You must be signed in to fork a gist
-
-
Save BlakeGardner/5587269 to your computer and use it in GitHub Desktop.
Syntax highlighting in nano on Mac OS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Last updated May, 2024 for Apple silicon Macs | |
| # Install Homebrew if you don't already have it: https://brew.sh | |
| # install nano from homebrew | |
| brew install nano nanorc | |
| # update your nanorc file | |
| echo 'include "'"$(brew --cellar nano)"'/*/share/nano/*.nanorc"' >> ~/.nanorc | |
| # close and re-open your terminal and you'll have syntax highlighting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main difference between the two code snippets lies in how they handle the installation and configuration of
nanoandnanorcusing Homebrew on macOS.Key Differences:
nanorc, while the second snippet (@lorthirk) does not. However, nano might still include syntax highlighting files that can be used without the separate nanorc formula.nanoCellar and includes syntax highlighting files from there. The second snippet uses a fixed path that assumes Homebrew's standard symlink behavior.nanoformula. The fixed path in the second snippet might break if Homebrew changes its symlink structure or if nano formula's installation path changes.Choosing Between Them
nanoin a way that's dynamically linked to Homebrew's Cellar structure.nanoincludes necessary syntax highlighting files in/usr/local/share/nano/.Given the current Homebrew structure and
nanoformula, both approaches should work, but the dynamic path might offer more future-proofing against changes in Homebrew or the formulae.