Here is a script to easy change the default blue scheme of Midnight Commander.

Unpack the archive and do:

./mc_change_theme.sh puthre.theme

To revert to the default scheme just:

./mc_change_theme.sh default.theme

The script will modify your ~/.mc/ini file. Please make sure that Midnight Commander is not running when you change your theme.

Here is how a theme file looks:
BASE_COLOR=lightgray,blue
NORMAL=lightgray,blue
SELECTED=black,cyan
MARKED=yellow,blue
MARKSELECT=yellow,cyan
ERRORS=white,red
MENU=white,cyan
REVERSE=black,lightgray
DNORMAL=black,lightgray
DFOCUS=black,cyan
DHOTNORMAL=blue,lightgray
DHOTFOCUS=blue,cyan
VIEWUNDERLINE=brightred,blue
MENUHOT=yellow,cyan
MENUSEL=white,black
MENUHOTSEL=yellow,black
HELPNORMAL=black,lightgray
HELPITALIC=red,lightgray
HELPBOLD=blue,lightgray
HELPLINK=black,cyan
HELPSLINK=yellow,blue
GAUGE=white,black
INPUT=black,cyan
DIRECTORY=white,blue
EXECUTABLE=brightgreen,blue
LINK=lightgray,blue
STALELINK=brightred,blue
DEVICE=brightmagenta,blue
CORE=red,blue
SPECIAL=black,blue
EDITNORMAL=lightgray,blue
EDITBOLD=yellow,blue
EDITMARKED=black,cyan
ERRDHOTNORMAL=yellow,red
ERRDHOTFOCUS=yellow,lightgray

Here is the result:
mc.png

58 Comments

Leave a Reply to manio Cancel reply

  • Thanks… the default colors were killing me… I can work again.

  • This is a neat script.

    May I suggest a slight improvement (for those of us stuck in non-Linux land)? When you test that mc is not running, just use ps and grep, rather than pidof (which is a Linux-only utility I think). Since we don’t actually care what the pid is, only that it’s running, you could rely on grep’s exit code and do this instead:

    if ( ps | grep mc > /dev/null ) then

    That should work on any system with bash, ps and grep installed, which I think covers off Cygwin, Mac OS X, *BSD and Solaris.

    I’m going to be a happy MC themer with your script!

    Cheers,
    m

  • Thanks for the suggestion. I modified the script as you suggested.

  • Same here, the default theme was killed by my terminal color settings. Now I can use it properly again 🙂

    Thanks alot!

  • Your script has been discovered in Belgium, and used !!!
    It rocks !

  • A better ps/grep would be this:
    if ( ps aux | grep mc | grep -v mc_change_theme >> /dev/null ) then

    Which will exclude the ‘mc_change_theme’ from the list.
    Then you can add an exit 1 there and stop the script from executing the theme change

  • Hello thank you for the script very nice. I would love to see more of these themes anyone out there got any they want to share?

  • Nice script!

    PS: comment #1 was written by an inconsiderate Romanian guy who didn’t bother to write English.

  • Good effort.
    It has a few little issues when being used on FreeBSD, I had to change the path to the bash binary, would be good if it could work under standard old /bin/sh
    It would be easier if the program just warned not to have mc running, I still had a bunch of processes that had the letters ‘mc’ in my background so I had to hash out this check code.

    Also I think by far the best mc colors are the ones that are default in the modded version of mc which is mc-light, only problem with mc-light is that it has heaps of bugs. If we could get mc-lights colors on standard mc I would be in heaven.

  • Used or proposed check for running “mc” isn’t working, cause:
    1. this expression “if ( ps | grep mc > /dev/null ) doesn’t work at all
    2. this expression “if ( ps aux | grep mc | grep -v mc_change_theme >> /dev/null ) then” work, but they catch anything like “mc” “xxxmcxxx” and of course grep process itself.

    here is my version of check for running mc in right way:

    if ( ps axu | grep -w [m]c > /dev/null ) then

  • Changed the way I check for mc running as Nifty suggests (thanks Nifty).
    I also changed /bin/bash to /bin/sh as Thebeastie suggests (thanks Thebeastie)

  • hi, thank you for this script!
    there is a little inconsistency with the manfiles. base_color is no color-keyword. I think the color names in “base_color=lightgray,blue” are ignored. You could write

    xterm=normal=white,black:marked=red,black
    rxvt=normal=yellow,black:marked=red,black

    in this case, mc would show normal text in a xterm in white and in a rxvt terminal in yellow.
    If you use base_color instead of xterm or rxvt, it is used for all terminals. I think the color names in “base_color=lightgray,blue” are ignored. I think cool would be a syntax for the theme file like:

    [base_color]
    NORMAL=white,black
    MARKED=red,black
    [xterm]
    NORMAL=yellow,black

    this would generate

    base_color=normal=white,black:marked=red,black
    xterm=normal=yellow,black

    by the way, where did you find the Keywords ERRDHOTNORMAL and ERRDHOTFOCUS?

  • I think I found all the keywords in Midnight Commander source code.

  • Great! With your script I figured out for the first time
    how to set MC’s colors.
    One remark though: You are using the source command
    which is available in bash but in other shells
    maybe not.
    For me it failed first and then worked after I changed
    the first line into:
    #!/bin/bash

  • Hello. This is great, thx 4 taking the time to do this. And fore the rest of us, especially lazy ones, pls find anonther theme based on this, with colors a bit warmer. The important lines go above:

    BASE_COLOR=gray,black
    NORMAL=white,black
    MENU=yellow,gray
    VIEWUNDERLINE=black,green
    EDITNORMAL=white,black
    EDITMARKED=black,white
    MENUHOT=red,gray
    DIRECTORY=yellow,gray
    EXECUTABLE=brightgreen,gray
    DEVICE=magenta,gray
    INPUT=yellow,gray
    LINK=brightcyan,gray
    STALLEDLINK=white,gray
    REVERSE=brightmagenta,black
    SELECTED=black,brown
    MARKED=black,lightgray
    MARKSELECT=black,yellow

    Cheers

  • Thank you Bobby. I’ve added your theme to the archive (bobby.theme).

  • THX! Great help to create rottex.theme for making mc adequate for night-shifts and still have some original mc-feel 🙂 See you in heaven !

    BASE_COLOR=lightgray,black
    NORMAL=lightgray,black
    SELECTED=black,cyan
    MARKED=yellow,black
    MARKSELECT=yellow,cyan
    ERRORS=white,red
    MENU=white,cyan
    REVERSE=black,lightgray
    DNORMAL=black,lightgray
    DFOCUS=black,cyan
    DHOTNORMAL=yellow,lightgray
    DHOTFOCUS=yellow,cyan
    VIEWUNDERLINE=brightred,blue
    MENUHOT=yellow,cyan
    MENUSEL=lightgrey,black
    MENUHOTSEL=yellow,black
    HELPNORMAL=black,lightgray
    HELPITALIC=red,lightgray
    HELPBOLD=yellow,lightgray
    HELPLINK=black,cyan
    HELPSLINK=yellow,black
    GAUGE=white,black
    INPUT=black,cyan
    DIRECTORY=white,black
    EXECUTABLE=brightgreen,black
    LINK=lightgray,black
    STALELINK=brightred,black
    DEVICE=brightmagenta,black
    CORE=red,black
    SPECIAL=black,blue
    EDITNORMAL=lightgray,black
    EDITBOLD=yellow,black
    EDITMARKED=black,cyan
    ERRDHOTNORMAL=yellow,red
    ERRDHOTFOCUS=yellow,lightgray

  • Your script is really cool 🙂 Thank you for your work… but if i can suggest something: it could be nice if the script also removes the ini from the temporary dir.

  • I’ve just added korg.theme to the archive, thanks to Manio (Mariusz BiaÅ‚oÅ„czyk) and Korg (Dmitry Korzhevin).

  • You just saved me a lot of work. For some reason using green on black in Kubuntu’s Konsole made the colors hard to read in MC. Your script worked like a charm. Thank you!

  • From argentina, your script help me a lot, tnx !!

  • If blue-filled markers for tabs and spaces make you go crazy when you’re using the editor you should probably try something like ‘editwhitespace=gray,black’.

  • And while we’re at it… if the cursor disappears (turning black, really) right after deleting a marked block it is most likely because the background color is the same as the ‘editmarked’ foreground color. Try something like ‘editmarked=white,blue’.

  • Some of us might experience the cursor disappearing in the editor white space areas (like tabs and trailing line spaces). This is not a mc problem. I use mrxvt and the following line (taken from the mrxvtrc.sample) in ~/.mrxvtrc solved the problem:

    Mrxvt.cursorColor: #00ff00
    Mrxvt.cursorColor2: #000000

  • A more general problem is that the color defaults for X11 terminal emulators might be a little odd. See:

    http://www.midnight-commander.org/ticket/385

    Some values to put in ~/.Xdefaults is suggested:

    *VT100*color0: #000000
    *VT100*color1: #AA0000
    *VT100*color2: #00AA00
    *VT100*color3: #AA6600
    *VT100*color4: #000080
    *VT100*color5: #AA00AA
    *VT100*color6: #00AAAA
    *VT100*color7: #AAAAAA
    *VT100*color8: #555555
    *VT100*color9: #FF0000
    *VT100*color10: #00FF00
    *VT100*color11: #FFFF00
    *VT100*color12: #0000FF
    *VT100*color13: #FF00FF
    *VT100*color14: #00FFFF
    *VT100*color15: #FFFFFF
    *VT100*colorULMode: on
    *VT100*colorUL: #60AAAA
    *VT100*colorBD: #FFFFFF

    Log off and back to activate. All of a sudden the default blue might be a little less annoying…

  • hi,

    i was really emphasized finding some code to colourchange the mc on different consoles, but i’m suffering an error while executing the script: “./mc_change_theme.sh: 72: source: not found”
    shell executing “source rottex.theme” runs, with no output

    OS ubuntu 8.04.3
    scriptfolder /home/user/Desktop/mcthemes

    has anybody an idea?

    thanks & regards

    jens

  • Jens: You might try to replace #!/bin/sh
    with #!/bin/bash on the top of the script.

  • Really nice sript! Default MC is boring and ugly, but the “official way” to change this is really masochistic.

  • You may add the option

    editwhitespace=gray,black

    the default value is

    editwhitespace=brightblue,blue

    that really hurts your eyes when you are coding late.

  • Hi, when i diffed the ini file generated by your script with the original one i noticed some differences other than colors. It seemed that there where backslashes missing. It’s probably because “read” command treats “\” in a special manner. Using “read -r” solves the problem, but i’ve no idea if it can have some negative effect (for me it was OK).

  • Awesome job!
    One thing to note though:
    if ( ps axu | grep -w [m]c > /dev/null ) then
    also ‘detects’ mc running for other users. Possible solution:
    if ( ps axu | grep -w [m]c | grep `whoami` > dev/null ) then

  • Good solution. It helped me because I work with different servers, but I couldn’t easily see in what server I was working at. Thanks a lot.

  • @puthre: Thanks again!!!

    @MariusG: usefull for detects only owner mc sessions

  • if ( ps axu | grep -w [m]c | grep `whoami` > dev/null ) then

    Wow, really? so you use the all users flag for ps and then you grep for whoaim…. doesn’t anyone read manpages anymore? Jesus!

    And somewhere along this thread there were all kinds of suggestions around this if statement, has nobody heard of pgrep?
    I think even Linux distributions have that now.

    Also, for sourcing isn’t the . keyword a standard?

    Like:

    . /etc/ksh.kshrc

    I know this might come as a shock but not everyone uses bash.

    Now I’m finished being arrogant and picking on a script that I don’t even use. I’ll crawl back to my BSD cave.

  • Hello,
    Great little script, bravo and thank you!

    I do have one request, how can I change menus colour/backcolour?
    Here is what I mean, in this picture: http://www.shrani.si/f/3U/10z/p9WZ3V6/scrot20110508195051.png
    there is menu in original colour

    But as I click on it, it changes to what I want, here is picture:
    http://www.shrani.si/f/u/8W/sTNCS9D/scrot20110508195100.png

    Sorry for my broken English, so I want menus to ALWAYS be as in second picture.
    Also, I would like to apply that on bottom menus (for F1-F10)

    Thank you.
    Kind regards, Goran

  • @Goran – I think you should change MENUHOT=yellow,cyan in the theme file so that the second color (background) is set to “black” and then reapply the theme

  • Ola puthre, and thank you for your answer

    I use yours theme, here is the code:

    BASE_COLOR=gray,black
    NORMAL=white,black
    MENU=yellow,black
    MENUHOT=red,black
    VIEWUNDERLINE=black,green
    EDITNORMAL=white,black
    EDITMARKED=black,white
    DIRECTORY=brightblue,gray
    EXECUTABLE=brightgreen,gray
    DEVICE=magenta,gray
    INPUT=yellow,gray
    LINK=brightcyan,gray
    STALLEDLINK=white,gray
    REVERSE=brightmagenta,black
    SELECTED=black,green
    MARKED=yellow,green
    MARKSELECT=black,yellow

    If I change Menu options it changes to colour set in theme but only if I click on it…
    As I move away I get that ‘original’ light blue…
    Menuhot changes the selected item…

    I want the top and bottom line to stay coloured as theme suggests,
    (top line in 2nd picture)
    not to turn ‘light blue’ as in first picture as I move away from it…

    I use gentoo os and ratpoison wm, terminal is (one and only) xterm, if this info helps to help me out…
    Don’t get me wrong, it is much better than original, but I would like to have it the way I want…

  • Thanks puthre and all the people for your work.

  • Thanks to all the people who created script and themes!

  • @Ole G. — July 3, 2009 @ 2:23 pm Ole: did rm ~/.Xdefaults as it did screw up the distinguishing between an mp3 and folder in my Konsole… there should be sync between those chars displaying and enter accepting technologies. other wise its chaos.

  • Wooooow, I was making a lot of research about this. Thanks a lot, thank you very much.
    I was to make a very litle change because archlinux, but it is a great solution, I don’t like the mc colors in urxvt, I couldn’t read the text.

  • Idea/update for script..

    #!/usr/bin/env bash – Getting the right bash path.

    and $HOME/.mc is now moved (in some cases) into $HOME/.config/.mc

  • Excellent piece of work. Simple, useful, small, tiidy, quick to deploy, and without deps…. Elegance!

  • Thank you very much! You saved my eyes from being burned by the bright cyan. =)