Midnight Commander config dir location startup option

mc

If you run
mc -F
you'll see there are [System data] config directory and [User data] config directory

[System data]

Config directory: /etc/mc/

[User data]

Config directory: /home/<username>/.config/mc/

First is system-wide, the second is User specific.

The second one seems to be dependent on user's home location;
in other words, it is bound to it. That means if you want to (temporarily) start mc with an alternate config as the same user you cannot do it w/o changing (and exporting) the HOME variable prior to it.
This 'Changing-HOME-prior-to start' workaround, though does the trick,
is hardly acceptable, as it well… does modify the user HOME.

Do you think there is a way to either

  1. Change the user config dir dynamically before the mc starts (command line option would be the most appropriate thing, but it does not seem to be there)

  2. Restore 'natural' HOME for user just after mc started, if changing HOME before is the only way to change user dir location

mc instances configured differently must not interfere each other if running simultaneously.

Best Answer

That turned out to be simpler as one might think. MC_HOME variable can be set to alternative path prior to starting mc. Man pages are not something you can find the answer right away =)

here's how it works: - usual way

[jsmith@wstation5 ~]$ mc -F
Root directory: /home/jsmith

[System data]
<skipped>

[User data]
    Config directory: /home/jsmith/.config/mc/
    Data directory:   /home/jsmith/.local/share/mc/
        skins:          /home/jsmith/.local/share/mc/skins/
        extfs.d:        /home/jsmith/.local/share/mc/extfs.d/
        fish:           /home/jsmith/.local/share/mc/fish/
        mcedit macros:  /home/jsmith/.local/share/mc/mc.macros
        mcedit external macros: /home/jsmith/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /home/jsmith/.cache/mc/

and the alternative way:

[jsmith@wstation5 ~]$ MC_HOME=/tmp/MCHOME mc -F
Root directory: /tmp/MCHOME

[System data]
<skipped>    

[User data]
    Config directory: /tmp/MCHOME/.config/mc/
    Data directory:   /tmp/MCHOME/.local/share/mc/
        skins:          /tmp/MCHOME/.local/share/mc/skins/
        extfs.d:        /tmp/MCHOME/.local/share/mc/extfs.d/
        fish:           /tmp/MCHOME/.local/share/mc/fish/
        mcedit macros:  /tmp/MCHOME/.local/share/mc/mc.macros
        mcedit external macros: /tmp/MCHOME/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /tmp/MCHOME/.cache/mc/

Use case of this feature:

You have to share the same user name on remote server (access can be distiguished by rsa keys) and want to use your favorite mc configration w/o overwritting it. Concurrent sessions do not interfere each other.

This works well as a part of sshrc-approach described in https://github.com/Russell91/sshrc

Related Question