If you’ve eved needed to code in linux probably at least several times you’ve spent long hours searching for syntax error …. just to find a missing quotation mark.
Solution? Nano editor
Table of Contents
1) Download & install
Let’s start with downloading nano.
# CentOS / RedHat / Fedora
sudo yum -y install nano
# Debian / Ubuntu
sudo apt-get -y install nano
Now let’s assume that you have Asterisk installed in /etc/asterisk
directory. Go to the dir and edit extensions.conf
file.
cd /etc/asterisk
nano extensions.conf
And what can see … let’s face it … it’s nothing fancy.
So let’s download pre-created .nanorc
file into /usr/share/nano/
directory.
cd /usr/share/nano/
wget https://files.hotkey404.com/blog/asterisk.nanorc -O asterisk.nanorc
There is a file that contains all syntax highlights: /etc/nanorc
. Just add new line to this file to use asterisk.nanorc
file you’ve just downloaded.
echo include "/usr/share/nano/asterisk.nanorc" >> /etc/nanorc
Now the same file looks a lot better.
2) Customization
The file you downloaded is one of the versions I’m using. Of cource just can adjust syntax, colors and …. all other stuff according to official documentation (https://www.nano-editor.org/dist/latest/nanorc.5.html). So let’s explain some basic stuff.
syntax "/etc/asterisk/.conf" "/.*.conf"
– this line defines which files should use this nanorc file
## Separating characters or
#color green "({|}|(|)|]|[|`||$|<|>|!|=|&||)"
– lines commented with #
are NOT being used
color
vs icolor
– ‘i’ stand for case-insesnitive (eg. Confbridge is not the same as ConfBridge)
"^(s)(#)include(s)(=>|=)(s)<.+>"
– all this stuff looks scary, but it’s just a REGEX expression. Just practise using one of online regex testers. I’m using https://regex101.com/
The same *.nanorc
file can be prepared for basically anything (eg. sh, html, php, js files). But since here we’re training Asterisk let’s stick to that.