In this entry I will guide you to update the standard terminal editor used by Ubuntu from its classic 2009 revision to its latest release.
GNU nano is the default terminal text editor for Ubuntu but is also used as a fallback editor in case your system fails. This might be one of the reasons why the default nano version is held back and why you may not want to apply this update.
At the time of writing a visit to the official GNU nano homepage reveals the current stable nano version is
2.4.3 2.7. While most Ubuntu installs are running 2.2.6. So let’s update!
Compile and install
First we remove the existing nano package and install some dependencies that we will need to compile nano from source. If you’re curious the libmagic-dev package is used to auto-detect file types for nano’s syntax highlighting feature.
sudo apt-get build-dep nano sudo apt-get install libmagic-dev
Now download the nano 2.7 source and extract it.
cd ~ wget http://www.nano-editor.org/dist/v2.7/nano-2.7.0.tar.gz tar -xf nano-2.7.0.tar.gz cd nano-2.7.0
Run the configuration script, I apply the following compile option.
–enable-utf8 turns on UTF-8 character encoding support which is in widespread use.
You can see a complete list of options available by using help.
Now compile and install nano. You will see a lot of debugging feedback that can safely be ignored.
make sudo apt-get remove nano sudo make install
When it is done let’s test nano to make sure it installed correctly.
source ~/.bashrc nano -V
Change the default settings
The nano install copies a sample settings file into the etc directory. We will duplicate this file to our home directory and apply our own custom settings.
cp ~/nano-2.7.0/doc/nanorc.sample ~/.nanorc nano ~/.nanorc
Go through the .nanorc settings file and uncomment any features you want turned on. I personally enable.
set constantshow set smooth set titlecolor brightwhite,blue set statuscolor brightwhite,green set keycolor green set functioncolor yellow set include "/usr/local/share/nano/*.nanorc"
set constantshow implements a live cursor positioner.
set smooth improves the scrolling smoothness.
set titlecolor, set statuscolor, set keycolor, set functioncolor applies colour to the nano user interface.
set include “/usr/local/share/nano/*.nanorc” enables colourisation of code markup and syntax.
Save your settings by pressing CTRL and the letter o and you are done!
If you ever find yourself wanting to revert back to the original nano installed by Ubuntu, you can do the following removal.
apt-get autoremove nano
You may need to remove the default configuration that was installed by nano 2.4.2 as it contains invalid directory paths.
sudo rm /etc/nanorc
Then install classic nano.
sudo apt-get install nano nano -V