Skip to content

Instantly share code, notes, and snippets.

@fevangelou
Last active January 3, 2024 14:43
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save fevangelou/be744753730e86b8783fd481f311a7c9 to your computer and use it in GitHub Desktop.
Save fevangelou/be744753730e86b8783fd481f311a7c9 to your computer and use it in GitHub Desktop.
Install Nano Editor (with syntax highlighting) on MacOS without using Homebrew [updated Jan 2024]
#!/bin/bash
# Install Nano Editor (with syntax highlighting) on MacOS without using Homebrew
# You can get the latest version number from https://www.nano-editor.org
# Instructions:
# - First off, download this Bash script from the browser & make it executable:
# $ chmod +x install_nano_on_macos_without_homebrew.sh
# - If you have "wget" installed (you most likely do), just run the script with:
# $ ./install_nano_on_macos_without_homebrew.sh
# ...and you're ready.
# - If you don't have "wget" installed, download the latest release of the Nano Editor in *.tar.gz
# from https://www.nano-editor.org and make sure the version referenced in the *.tar.gz file is also
# referenced in the VERSION specified after these comments & then run the script with:
# $ ./install_nano_on_macos_without_homebrew.sh
# ...which will use the file your downloaded for the Nano Editor to install it directly.
VERSION="7.2" # As of Jan 2024 - set the version number here
cd ~/Downloads
if [ ! -f "nano-${VERSION}.tar.gz" ]; then
wget -O nano.tar.gz https://www.nano-editor.org/dist/latest/nano-${VERSION}.tar.gz
fi
tar -xvf nano.tar.gz
mv nano ~/.nano
cd ~/.nano
./configure
make
sudo make install
touch ~/.nanorc
cat > "~/.nanorc" <<EOF
## Some defaults
set autoindent
set historylog
set indicator
set linenumbers
set locking
set mouse
set softwrap
set stateflags
set tabsize 4
set tabstospaces
## Enable syntax highlighting in Nano
include ~/.nano/syntax/*.nanorc
EOF
exit
@fevangelou
Copy link
Author

This script was written for the Bash shell. My guess is you're on Zsh (the new shell used in macOS).

In any case, since this guide was written some time ago, I would recommend installing Homebrew and then just do brew install nano and you're done.

@Chrisdoan9
Copy link

Chrisdoan9 commented May 24, 2022

Hi @fevangelou

I brew install nano then bash and even update to nano 4.0 but I still got that error. I switch from zsh to bash.

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