DEV Community

knowvergreen
knowvergreen

Posted on

`Nano`sphere

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!

Black & White two hands, fist close, with thumbs touching 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 βœ…

Screenshot of terminal showing creation of nano and backup folders

:~$ mkdir -p ~/.config/nano ## contains the nanorc file

:~$ mkdir -p ~/.cache/nano/backups/ ## backup folder
Enter fullscreen mode Exit fullscreen mode

A person holding a tablet and raising her hand Description<br>
automatically generatedPhoto 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?!

A person in a hat Description automatically<br>
generatedPhoto by Brett Sayles on Pexels.com

Really!!! Why!!!

A person in a suit with his hands up in front of a computer<br>
Description automatically generatedPhoto 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

A group of men standing in a line, with the words "resistance is futile"Image by George from Pixabay

So, now none of my shit worked! I'm laughing at myself and pulling my hair and laughing again 🀣

A person holding her hair Description automatically<br>
generatedPhoto 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
Enter fullscreen mode Exit fullscreen mode

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 πŸ˜ŽπŸ™Œ

A group of people in a cloud of colored powder Description<br>
automatically generatedPhoto 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:

A screenshot of a computer terminal, linux, showing nano editor

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.

A screenshot of computer screen with text and a red box pointing to changed section of config file

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 of Man shrugging 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 #############
Enter fullscreen mode Exit fullscreen mode

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 #############
Enter fullscreen mode Exit fullscreen mode

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.

A screenshot of nano editor opened in the terminal

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...!?

A child with his hand on his head Description automatically<br>
generated 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.

Screenshot of nano settings with a red conversation box

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 πŸ˜ŠπŸ™Œ

A group of people standing together Description automatically<br>
generated 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 πŸ™Œ

Screenshot of ubuntu terminal search of aspell language afrikaans

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 πŸ€£πŸ˜‚

A screenshot of some of the available Aspell dictionaries

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!

Screenshot of Aspell suggestion after pressing F12

Fin πŸ™‹β€β™‚οΈ

I'm satisfied with the outcome πŸ™ŒπŸ˜

A person holding a glass of liquid Description automatically generated Photo by Terricks Noah on Pexels.com

Hope this helps!

Thank you,

Blogging out! 😎😊✌️

Top comments (0)