Skins and color themes for Midnight Commander

MC (Midnight Commander) is a great piece of software and I use it a lot, even when I’m using a graphical desktop environment. Unfortunatly, it had to reach version 4.7 and many-many years of development until it got proper color themes support! But I’m not complaining (oh well, maybe a little) – I am now the happy user of MC 4.7 running on my brand-new Ubuntu 10.4 install, and I just noticed the skins support.

Of course, it is not perfect and it’s not the best approach either, but before we’ll get into that, let me show you an example of what coloring MC was like a few releases ago:

[Colors]
base_color=normal=white,default:selected=white,blue:marked=brightcyan,default:markselect=brightcyan,blue:errors=white,red:input=white,default:reverse=black,lightgray:menu=brightcyan,blue:menusel=blue,lightgray:menuhot=red,blue:menuhotsel=red,lightgray:gauge=black,brightcyan:dnormal=brightcyan,blue:dfocus=blue,lightgray:dhotnormal=brightred,blue:dhotfocus=brightred,lightgray:helpnormal=brightcyan,blue:helpbold=white,blue:helpitalic=brightgreen,blue:helpslink=brightred,blue:helplink=yellow,blue:executable=brightgreen,default:directory=brightblue,default:link=gray,default:special=magenta,default:device=yellow,default:core=brightred,default:stalelink=brown,default:viewunderline=lightgray,default:editnormal=lightgray,default:editbold=white,default:editmarked=blue,lightgray

You see that horrible cryptic line? It was supposed to go into ~/.mc/ini and would change MC colors. Any typo would lead to colors not loading. And it doesn’t end here.

Since that file is overwritten when you exit MC, you can’t edit it with MC’s internal editor, so you have to edit a copy, exit MC and overwrite the file. Yes, talk about dubious design decisions. So I’m not going into that.

What I am going to write about is how the skins support work in MC 4.7 or later. The skins are simple ini files that are placed in /usr/share/mc/skins.

You can load any of the skins there with the command:

$ mc -S skinfile

Don’t write any path or the .ini extension of skinfile.

If you want to make the changes permanent, you need to edit the ~/.mc/ini file to contain this line:

[Midnight-Commander]
skin=ovidiu

Of course, make sure you don’t have MC started or you’ll lose the settings when you exit it. Edit a copy and replace the ini file:

$ cd ~/.mc
$ cp ini ini.new
$ mcedit ini.new
(do your stuff)
$ mv -f ini.new ini

MC comes with some predefined skins, so it’s pretty easy to “fork” one of them so you can customize it to your liking.

The skins support is (incompletely) documented on the mc wiki. The options that are not described on the wiki are pretty easy to understand – for exemple the characters used to draw the boxes.

To create a new skin, you just need to copy one of the existing files (I used default.ini) and edit it. After you save your changes, you should first test it with mc -S skinfile. The changes are not permanent, so if you messed up the display, you don’t have to kill all your MC settings.

The bad news is that there’s no option in the interface to choose the skin and no documented support to load a skin from your own home directory, so if you don’t have root access (or a friendly sysadmin), you can’t use the skins support.

Leaving the bad parts aside, in less than 20 minutes I was able to convert the horrible line at the beginning of the post to a complete skin, and now my MC changed looks from this:

to this:

You can download my skin file here – just save it to /usr/share/mc/skins and you can use it.

Enjoy and let me know what you think in the comments! Also, if you have improvements, I’m interested to see them!

For my romanian small-biz friends: make sure you read the NOVIT news!

Share

6 comments

  1. [...] updated MC from version 4.7 to 4.7.5 on my Ubuntu system, from a PPA repository. Unfortunatly, the MC skin I was using didn’t look very nice – some new keys appeared on the skin files and the default looked [...]

  2. Keith Bowes says:

    Well, in older versions of Midnight Commander, you could do any of the following:
    1.
    a. Exit Midnight Commander.
    b. vi ~/.mc/ini
    c. Add the color-scheme line
    d. Restart Midnight Commander.
    2. Use the MC_COLOR_TABLE environment variable (that’s what I did).
    3. Pass the -C option (preferably set it in your desktop or window manager’s menus or create an alias or script for it).

    Hm, I can load the skin from my home directory. What I’ve been doing is using the MC_SKIN environment variable.

    However, I now have slightly different skins for 4.7.5.1 and the latest git (which I use for keeping my translation up-to-date), I’ve moved it to my ini file (use the skin directive in the [Midnight-Commander] section); it looks in the skins subdirectory of your configuration directory (~/.mc/skins in 3.7; $XDG_DATA_HOME/skins in the latest code).
    [Not that I'm that brilliant; I just found that hat tip at http://blog.miranda.or.at/unix/editing-skins-for-midnight-commander today; the same web search which lead me to this entry.]

    I can’t say where I see that the skins are any more fault tolerant than the color table; in both, an unrecognized keyword makes it resort back to the default color.

  3. Ovidiu says:

    @Keith, great info, thank you! I didn’t know about the environment variables, this makes it easier to play with the colors.

  4. Ovidiu says:

    @Greg, nice! Too bad I need to patch htop, I’ll try it when I’ll have some free time. Did you submit it upstream, maybe it’ll get included on next release?

  5. [...] found this: http://blog.mybox.ro/2010/05/10/skin…ght-commander/ I haven't tested it, but I plan to! Thanks for letting me that there are such things as skins [...]

Leave a Reply

Your email address will not be published. Required fields are marked *


1 × = three

CommentLuv badge