Blastoff π
You know!!! I just wanted to make nano work for me, and I went down this rabbit hole, just a bit ππ€£
If I want to get line numbers, have mouse functionality, and at least be able to use CTRL-V
, CTRL-C
, and CTRL-F
π«€ you knowπ§ things I'm used to on non-terminal things π© then, I thought π€ I need to setup a file to customize nano to my taste, right? Sure do!
Photo by srini on Pexels.com
The Yellow Brick Road
Welp, I went down the yellow brick road, or should I say fell down the rabbit hole?! π Either way, I created a ~/.config/nano/
directory and placed a .nanorc
file in there. I also created a ~/.cache/nano/backups/
file to act as another location where data from what I'm working on gets saved too when I hit save on the original. The way I'm seeing it is like a manual versioning π.
Now, I said something key here, hit save. So, it doesn't save automatically. That's key, backups only occur when original saves π Either way, initial goal β
:~$ mkdir -p ~/.config/nano ## contains the nanorc file
:~$ mkdir -p ~/.cache/nano/backups/ ## backup folder
Photo by Andrea Piacquadio on Pexels.com
Nope, not done, wait a minute, didn't stop β there. I wanted to keep playing, oops, I meant experimenting with it... and for sure, yep, my experimenting π€¬ it up π€£π I mean, I had my line numbers, auto indent, and CTRL-V
, CTRL-C
, CTRL-S
and mouse support πͺ€, but then I had to go and be like why not add syntax
support and shit π€π
Me looking at myself ππ€£ I mean... What could go wrong?!
Photo by Brett Sayles on Pexels.com
Really!!! Why!!!
Photo by Andrea Piacquadio on Pexels.com
Shit went wrong! π
I indeed went down that rabbit hole again π° and, too long didn't read (TLDR), I landed on Scopatz/nanorc Github, which had a nice magic wand πͺ in the form of an install.sh π Welp, I would like to say that all went well, but as you can probably tell by the next paragraph, I π€¬ again π€£ I followed steps and all, the issue though, I wasn't expecting to get assimilated
So, now none of my shit worked! I'm laughing at myself and pulling my hair and laughing again π€£
Photo by SHVETS production on Pexels.com
Nano
wasn't reading the ~/.config/nano
directory anymore. No matter what I tried to do, from symlink
or renaming the .nanorc
file in that directory and re-symlink
or adding the configs
I had in my ./nano/nanorc
to the .nanorc
file created at the ~/.nano/nanorc.nanorc
, nothing and I mean nothing worked. Instead, the errors
came to work though π
Error in ~/.nano/nanorc.nanorc on line 52: Command "set" not allowed in included file
Error in ~/.nano/nanorc.nanorc on line 59: Command "include" not allowed in included file
Error in ~/.nano/nanorc.nanorc on line 76: Command "bind" not allowed in included file
So, after a bit of looking around trying to find how to get things working together and even trying things out myself, of course I find that nano has some minimal syntax enabled by default, to my understanding, of the nano wiki on Gentoo.
I got two other things out of that too π One, if I want to get real use out of syntax support in nano
, I will have to enable plugins
and things, which I thought I was doing π Two, something from the Gentoo Configuration section caught my eyes. Guilty, β, I was skimming through the text, catching what I think was important, to me, and caught this: "to change options only for one user, set the option in the user'sΒ ~/.nanorc
Β file. As a general rule, files present in a user's $HOME
directory override system wide settings". So now I know why I got "Borged", or assimilated, for those who don't know Star Trek parlor π
Anyways, what I decided to do was remove the created directories, which were done by the automated installer from scopatz's githut. I copied his configurations, to a custom .nanorc
file π§ I called syntax_config.nanorc
and then I link it to our my main ~/.config/nano/nanorc.nanorc
, in same directory, through an include
tag and boom we got nano
back baby ππ
Photo by Marcin Dampc on Pexels.com
Side trick π
Side note, when I ran the auto installer, provided by scopatz, there was an error message that kept popping up when accessing nano
:
Error in ~/.nano/nanorc.nanorc on line 26: Color 'normal' takes no prefix
To fix this problem, I opened the ./nanorc.nanorc
file and edited the line that said icolor brightnormal " brightnormal"
by removing prefix word bright
from both normal
tags, then saved and exited.
Now, if something similar ends happening somewhere π, then what I would do is go into the file and copy everything and save them into a text document and back it up somewhere so that I can create that file I spoke of earlier, above β¬οΈ
Now, I don't know about you, but I am good today with being a glutton for punishment, so I went ahead and pasted the install.sh, with the corrected section, from scopatz's auto installer so that if I somehow misplaced it, hey, π€·, I got it here too π
curl https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh | sh
from his Github
illustration by Firkin - uploaded on Openclipart.org
############# NANO SYNTAX HIGHLIGHTING START #############
## Here is an example for nanorc files.
##
syntax "Nanorc" "\.?nanorc$"
comment "#"
## Possible errors and parameters
icolor brightred "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
## Colors
icolor black " black"
icolor red " red"
icolor green " green"
icolor yellow " yellow"
icolor blue " blue"
icolor magenta " magenta"
icolor cyan " cyan"
icolor white " white"
icolor normal " normal"
icolor brightblack " brightblack"
icolor brightred " brightred"
icolor brightgreen " brightgreen"
icolor brightyellow " brightyellow"
icolor brightblue " brightblue"
icolor brightmagenta " brightmagenta"
icolor brightcyan " brightcyan"
icolor brightwhite " brightwhite"
icolor normal " normal"
icolor ,black ",black "
icolor ,red ",red "
icolor ,green ",green "
icolor ,yellow ",yellow "
icolor ,blue ",blue "
icolor ,magenta ",magenta "
icolor ,cyan ",cyan "
icolor ,white ",white "
icolor ,normal ",normal "
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
icolor yellow "^[[:space:]]*(set|unset)[[:space:]]+(errorcolor|functioncolor|keycolor|numbercolor|selectedcolor|statuscolor|stripecolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
## Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backupdir|boldtext|brackets|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|errorcolor|fill|functioncolor|guidestripe|historylog|jumpyscrolling|keycolor|linenumbers|locking|matchbrackets|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nopauses|nowrap|numbercolor|operatingdir|positionlog|preserve|punct|quickblank|quotestr|rawsequences|rebinddelete|regexp|selectedcolor|showcursor|smarthome|smooth|softwrap|speller|statuscolor|stripecolor|suspend|tabsize|tabstospaces|tempfile|titlecolor|trimblanks|unix|view|whitespace|wordbounds|wordchars|zap)\>"
icolor green "^[[:space:]]*(bind|set|unset|syntax|header|include|magic)\>"
## Strings
icolor white ""(\\.|[^"])*""
## Comments
icolor brightblue "^[[:space:]]*#.*$"
icolor cyan "^[[:space:]]*##.*$"
## Trailing whitespace
icolor ,green "[[:space:]]+$"
############# NANO SYNTAX SETTINGS FIN #############
Getting there π
I got help when it came to creating my .nanorc
file too. I went to these two sites:
I especially ripped from bash-prompt.net (THANK YOU!!!!). Bash-prompt.net made it easier to understand nanorc-editor.org site and helped me to add the set mouse option to it. As I go, I'll look to add more options, that make sense to me.
############# NANO SETTINGS START #############
# Non-default settings
set atblanks # wrap line at blanks.
set cutfromcursor # CTRL+K cuts from cursor position to end of line.
#set nohelp # Disable the help information (CTRL+G to view the help screen).
set softwrap # Enable softwrap of lines.
set suspend # Enables CTRL+Z to suspend nano.
set tabsize 4 # Sets tab-to-spaces size to 4.
set tabstospaces # Converts TAB key press to spaces.
include "/usr/share/nano/*.nanorc" # Enables the syntax highlighting.
include "~/.config/nano/Syntax_config.nanorc" # Enables the syntax highlighting. Custom syntax - user
set speller "aspell -x -c" # Sets what spelling utility to use.
set constantshow # Displays useful information e.g. line number and position in the bottom bar.
set linenumbers # Lines are numbered.
set casesensitive # Case insensitive search.
set historylog # Save the last 100 history searches for later use.
set positionlog # Saves the cursor position between editing sessions.
set zap # Allows you to highlight text (CTRL+SHIFT+ARROW) and delete it with backspace.
set autoindent # A new line will have the same number of leading spaces as the previous one.
set indicator # Displays a scroll bar on the right that shows the position and size of the current view port.
set minibar # Displays file name and other information in the bottom bar. Removes top bar.
set mouse # . When enabled, mouse clicks can be used to place the cursor, set the mark (with a double click), and execute shortcuts.
# Enable and set a working backup directory
set backup # Creates backups of your current file.
set backupdir "~/.cache/nano/backups/" # The location of the backups.
# Shortcut key bindings
bind ^C copy main # CTRL+C - Copy
bind ^V paste all # CTRL+V - Past
bind ^F whereis all # CTRL+F - Find
bind ^S savefile main # CTRL+S - Save
############# NANO GENERAL SETTINGS FIN #############
Realizationπ‘
Now, things are running smooth, at least to me π€ Welp, too soon man! π I spoke to darn soon π€£
So, if I hit CTRL+X
to exit after making changes to whatever I'm
working on in nano during that buffer messaging, it seems, to me, that nano froze as I was still seeing that buffer message, as in screenshot.
Actually, nano was waiting on this dodo 𦀠It wasn't frozen π₯Ά. All I had to do was press (Y)
as I usually do when I exit after making changes to something in nano
and then nano
asking me if I wanted to apply
/save
the changes by selecting (Y)es
or (N)o
before completely exiting nano
.
Don't know why I was getting this buffer message/warning/info
though... I made a note of it as something seen ππ€¨. I don't think it's from the customization...!?
Image by Hanna Kovalchuk from Pixabay
Actually, yeah, my bad, it is from the customization. I enabled set nohelp
. I realized this when I spun up another VM and customized nano
there too. So, I disabled it by commenting it out #set nohelp
or, If I was inclined, I would just not include the option at all .set nohelp
While going through the config file, I found out that the help can be accessed by hitting CTRL-G
. I might need to put that down on a post-it notes somewhere π§π€£ As much as the help menu's been at the bottom, there, I got so used to it that I didn't notice it until it wasn't there anymore π and in looking to getting it back I learned something new by doing this exercise.
I'm glad, now I know that I get full access to greater definition right at my fingertips, literally ππ I don't always have to go online to find the info.
The story of the aspell
As an aside, I remembered that set speller "aspell -x -c"
, was part of the .nanorc
config from bash-promt.net too. Elliot Cooper, the person to whom the site belongs, and he did mention something about installing and setting up GNU Aspel, no instructions though π So, I went to GNU Aspel's site, and they do have an Appendix just on installing... π§π
So, yeah, no .deb file, no curl/wget, no apt repository that they maintain. OK, cool π no problem. I'll keep looking on Ubuntu side to see if Ubuntu has something π you know. I could see that GNU Aspel's appendix does seem to have a recipe for how to make
it myself if I wanted to go that route, as I pointed out earlier, however, since I have Ubuntu, I kept stomping the pavement and then it happened, I was able to find sudo apt -y install aspell aspell-en
instead ππ
Photo by Helena Lopes on Pexels.com
Curiosity didn't kill the cat πΌ
I had to do it ππ€£!! I went and I looked to see if another language was available for download, and sure enough Ubuntu had another one for download, for GNU Aspel π
sudo apt search aspell-af #Afrikaans
Yes, I kept the curiosity going π, that ain't going away man. So, I looked to see if GNU Aspel had other languages in general and yes, that they do. Now, I don't know if all of them are available on Ubuntu for download from their apt repository, as all I needed was English. Wasn't that curious I guess π€£π
Once I downloaded the dictionary of my choice, I evaluated it by opening one of my .nanorc
files and pressing F12
to fire up speller, sadly no autosuggestions like Microsoft Word or programs like that. It needs initial user interaction π«€π€· Ok, now that I see aspell
and now know it's working!
Fin πββοΈ
I'm satisfied with the outcome ππ
Photo by Terricks Noah on Pexels.com
Hope this helps!
Thank you,
Blogging out! ππβοΈ
Top comments (0)