macOS Mojave has v2.0.6 installed whereas the latest is 4.3 at the time of this writing.
1nano --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
1# install Homebrew
2/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3
4# use Homebrew to install nano
5brew 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
1/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:
1ln -s /usr/local/Cellar/nano/4.3/bin/nano /usr/local/bin/nano
1# ~/.aliases or ~/.bash_profile
2alias nano=/usr/local/Cellar/nano/4.3/bin/nano
1# ~/.bash_profile
2export PATH="/usr/local/Cellar/nano/4.3/bin/nano:$PATH"