Skip to content

Instantly share code, notes, and snippets.

@GLMeece
Last active March 7, 2024 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GLMeece/94b8dcc20b9785d5b783ba5498b52fdf to your computer and use it in GitHub Desktop.
Save GLMeece/94b8dcc20b9785d5b783ba5498b52fdf to your computer and use it in GitHub Desktop.
NANO on macOS and Windows

NANO on macOS and Windows

This should get you up and running with the installation and basic configuration of GNU Nano on both macOS and Windows. In the case of macOS, this will install a newer version of Nano that includes syntax highlighting.

macOS Installation

Homebrew

It is assumed you already have Homebrew installed. If not, then Verify or Install Apple's Command-line Tools and then proceed with the installation of Homebrew. 🍺

Installing GNU Nano

Just a straightforward brew install nano

Enabling Syntax Highlighting

  1. Execute: cd ~;nano .nanorc
  2. Add this line: include "/opt/homebrew/Cellar/nano/*/share/nano/*.nanorc"
  3. Type ⌃-o (control-o) and hit ⏎ (enter or return) to save the file.
  4. Type ⌃-x (control-x) to exit.

Windows 10, 11 Installation

It is recommended that you install Git with BASH as that turns out to be the most straightforward way to install the syntax highlighting.

Installing Nano

Although Chocolately is pretty nifty, I've found its installation of Nano on Windows a bit problematic. WinGet (built into newer Windows versions) is still pretty handy so I'm recommending this path for installation.

  1. Run PowerShell

  2. Run Get-ExecutionPolicy; if it returns Restricted, then execute:

    Set-ExecutionPolicy AllSigned
  3. Install Git if it's not already:

    winget install -e --id Git.Git
  4. Update either your user or the system PATH and add the following (reference):

    C:\Program Files\Git\usr\bin

Enabling Syntax Highlighting

In a PowerShell prompt:

  1. cd ~;nano .nanorc
  2. Add these lines (Git's BASH must be installed!):

    include "/c/Program Files/Git/usr/share/nano/*.nanorc"
    include "/c/Program Files/Git/usr/share/nano/extra/*.nanorc"
  3. Type ⌃-o (control-o) and hit ⏎ (enter or return) to save the file.

  4. Type ⌃-x (control-x) to exit.

Note: You may wish to add other options, as described in this document. Alternately, you could look at the official example .nanorc file.

@tommai78101
Copy link

tommai78101 commented Feb 9, 2024

  • Note, if Git-Bash is installed in a different location (e.g., D:\Git), then you will need to update the Git Bash installation paths in "Enable Syntax Highlighting", Step 2.
    • Example:
    include "/d/Git/usr/share/nano/*.nanorc"
    include "/d/Git/usr/share/nano/extra/*.nanorc"
  • There is no need to add /mnt prefix to the installation path, as these paths are for Windows (DOS-compliant paths).
  • You can use this nanorc compilation repository for all your Nano syntax highlighting needs. https://github.com/galenguyer/nano-syntax-highlighting

@GLMeece
Copy link
Author

GLMeece commented Feb 21, 2024

Thanks for your comments @tommai78101

FWIW, I just updated my instructions. I've found my original last setup step to be problematic, so it's a lot easier IMO to just add C:\Program Files\Git\usr\bin to the PATH environment variable.

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