Bored of looking at that black and white text for a while? You would want to enable or activate color themes in Nano editor which is really easy to do.
There are many languages supported for color theming within nano, such as
- C/C++
- PHP
- Ruby
- SH
- CSS
- Man
- Perl
- Python
- TCL
- HTML
etc
First you will want to open nanorc file with the command shown
1 |
sudo nano /etc/nanorc |
Then you would want to find include file that holds theming information such as one shown below
1 2 |
## Bourne shell scripts # include "/usr/share/nano/sh.nanorc" |
Mostly what you have to do is to uncomment this line so above will become this
1 2 |
## Bourne shell scripts include "/usr/share/nano/sh.nanorc" |
You can edit this file too, open one of the file in edit mode with nano
You will get something like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
## Here is an example for Bourne shell scripts. ## syntax "sh" "\.sh$" magic "(POSIX|Bourne.*) shell script text" header "^#!.*/(ba|k|pdk)?sh[-0-9_]*" icolor brightgreen "^[0-9A-Z_]+\(\)" color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|whil$ color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)" color green "-[Ldefgruwx]\>" color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>" color brightblue "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|install|let|ln|make|mkdir|mv|rm|sed|set|tar|touch|umask|un$ icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?" color cyan "(^|[[:space:]])#.*$" color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'" color ,green "[[:space:]]+$" |
You can change above mentioned colors to your taste for different things such as keywords, strings etc. icolor is case in-sensitve matching for the provided pattern.
For more information on nanorc files, you should check out this link
http://www.nano-editor.org/dist/v2.1/nano.html#Nanorc-Files
I activated colors for bash scripts, Text within my bash scripts under nano looks like this now
I hope that this article will be helpful to you. leave your comments if you would like to share any additional information.
Cheers
Leave a Reply