Upgrade nano to v4.3 on macOS

macOS Mojave has v2.0.6 installed whereas the latest is 4.3 at the time of this writing.

nano --version
 GNU nano version 2.0.6 (compiled 19:02:51, Feb 22 2019)
 Email: nano@nano-editor.org	Web: http://www.nano-editor.org/
 Compiled options: --disable-nls --enable-color --enable-extra --enable-multibuffer --enable-nanorc --enable-utf8

Use Homebrew to install nano

# install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# use Homebrew to install nano
brew install nano

If you check the version now, it’ll still show 2.0.6 because by default it uses the system version. The brew version is here: /usr/local/Cellar/nano/4.3/bin/nano

/usr/local/Cellar/nano/4.3/bin/nano --version
 GNU nano, version 4.3
 (C) 1999-2011, 2013-2019 Free Software Foundation, Inc.
 (C) 2014-2019 the contributors to nano
 Email: nano@nano-editor.org	Web: https://nano-editor.org/
 Compiled options: --disable-libmagic --enable-utf8

To make sure the Brew version of nano is run every time, you can:

  • symlink the bin file
  • or add it as an alias
  • or add it to \$PATH
ln -s /usr/local/Cellar/nano/4.3/bin/nano /usr/local/bin/nano
# ~/.aliases or ~/.bash_profile
alias nano=/usr/local/Cellar/nano/4.3/bin/nano
# ~/.bash_profile
export PATH="/usr/local/Cellar/nano/4.3/bin/nano:$PATH"