[clug] mc: was Text editor

Scott Ferguson scott.ferguson.clug at gmail.com
Wed Apr 8 18:39:13 MDT 2015


On 08/04/15 22:09, Bryan Kilgallin wrote:
> I respond to Scott's post.
> https://lists.samba.org/archive/linux/2014-October/033475.html
> 
>> If you find the whole text/console thing a little disorientating you
>> may find "mc"[*1] useful (clone of Norton Commander?).
> 
> Now I have installed that on my PC. It reminds me of Filer on my old
> HP200LX palmtop. "mc" seems to have powerful features. But how can I set
> it to not display hidden files?

MC -> F9 -> Options -> Panel Options -> Main Options -> Show Hidden
Files (unselect)

Reference: MC -> F1 (Help)

> 
>> F4 will (usually) give you nano to edit the selected file.
> 
> I used a shell link to my phone. Wherein I had a test text file. Which I
> moved to my PC's desktop. At first I saw a list of available editors,
> agreeing to the default "nano". But how can I now change that choice to
> a different editor?

In MC??
An MC "shell link"??
I've never experienced this "list of available editors". Are you
actually using MCs editor or the system defaults (alternatives)??
MC -> F9 -> Options -> Configuration -> Other Options (is "use internal
editor" checked?)


man mcedit??
man update-alternatives?? (I suspect you are using the system default
cli text editor)

> 
>> "Ctrl+x" to abandon changes, "Alt+F2" to save changes.
> 
> Unfortunately I had previously set my PC's function keys.

man mc (see the section on Keys).

> 
>> "Alt+F2" will bring up the mc menu options for the selected file -
>> very useful to those that don't have an ingrained memory of hotkeys
>> (and it has trivially editable functions).
> 
> As above, my function keys don't operate "mc" commands. Yes, clicking "2
> Menu" lists a staggering array of options!


F2 shows default options available for the filetype currently
selected/highlighted. You can easily (after 10 minutes study of the
macro language) edit those options and add additional functionality if
you want.

e.g. you use MC for archiving backups, enter a directory and choose F2,
amongst the options is to create a compressed archive of the current
directory (with the archive created outside it). You find the "make
bzip2" archive function useful, and the ability to customise the name of
the resulting archive but would like to add automatic datestamping.

edit /usr/local/sbin/DateString
#!/bin/bash
date +%H%M-%d%m%Y

chmod +x /usr/local/sbin/DateString


edit /etc/mc/mc.menu and add a new entry to the archive choices for F2
(you'll have to increment the existing index numbers above 5
accordingly) to add the following code:-

5       Compress and datestamp current subdirectory (tar.bz2) for backup
        Pwd=`basename %d /`
        echo -n "Name of the compressed file (without extension) [$Pwd]\n
`DateString` will be appended"
        read tar
        if [ "$tar"x = x ]; then tar="$Pwd"; fi
        cd .. && \
        tar cf - "$Pwd" | bzip2 -f > "$tar-`DateString`.tar.bz2" && \
        echo "../$tar-`DateString`.tar.bz2 created."


That will create a new F2 choice "5 Compress and datestamp current
subdirectory (tar.bz2)"


Likewise for rsync, generating digital signatures, etc, etc.


> 
>> [*1] Midnight Commander. Lightweight dual pane file menu and system
>> navigator (and much, much more).
> 
> I need to practise with this powerful retro tool, gain confidence at
> using it.
> 

Mini tutorial I studied at Google University:-
http://www.trembath.co.za/mctutorial.htmla

;p



Kind regards


More information about the linux mailing list