What’s your favourite text editor? In a recent blog entry I updated “The Script” for IOT fans and as usual, got myself incredibly frustrated with the lacklustre “Nano” editor that comes with Raspbian on the Raspberry Pi, only to discover that my backup editor “MCEDIT” is really only marginally better – this stuff is built primarily to please Linux fanboys and IMHO is not in the same ease-of-use league as NotePad++ on the PC – granted the latter is in a Windows environment and these are command line tools – but surely there must be something better?
There IS – I just found it at the weekend. I’ve added this to “The Script” today. The line below starts off the MICRO editor with (for example) script.sh opened in the current directory for editing.
I love the editor already – and it has proper control-C and control-V for copy and paste respectively. Open a readable file to play with and dive straight in… control-E brings up help at the bottom of the screen – and if you want to set up a theme – for example:
set colorscheme simple
Note that at this point, the colours are a bit basic – more on that toward the end – but first – to install this little wonder of an editor… Sitting on your PC running an SSH session (I use Mobaxterm) to the Pi as user pi (if you are using a Raspberry Pi)…
curl https://getmic.ro | bash
And of course true to my claim to being bone idle, I’ve updated the /etc/bash.bashrc file to have that “./micro” reduced to “e” (“ed” has already been taken) – I’ve also added the privileged version which I’ve called “se”.
And here they are added to my list of aliases in ./etc/bash.bashrc
Having mastered control-V for INTERNAL pastes, I noted that EXTERNAL pastes from Windows did nothing so I added the following:
sudo apt install xclip
External pastes seem to take half a second to appear but no matter. Full mouse support etc.
So now I had shortcut se for using the editor as SUDO (ie privileged user) – and that’s lovely but still the editor colors were boring compared to modern Windows editors.. the solution is to add 2 environment varibles to the end of /etc/profile using the new editor shortcut – add the two lines right at the very end of the file….
export MICRO_TRUECOLOR=1 export COLORTERM=24bit
and save using control-S then F10 to exit. You should reboot the PI for ease after setting these two variables… then, again in the editor – hit control-E then for example:
set colorscheme dukedark-tc
and the result when editing my script.sh
Rather than explain more here, I will just pass you to the editor’s home page – read all about it:
There are two issues I’m aware of with this editor – selecting offscreen and a disappearing cursor in 24-bit colour mode – I’m commenting in Github right now and a nightly version of micro fixes the former – as for the cursor – not yet. To get the latest version – for your computer you may need a different file if not a Raspberry Pi – there are Windows and many other nightly builds all in the same place…
tar xvzf micro-2.0.4-dev.15-linux-arm.tar.gz
That will create a folder with the micro editor file in it (micro) – I simplified the folder name they used down to simply “micro”. – ultimately I simply pulled the binary file into my PI folder so back as it was originally.
Comments below, please.