Midnight Commander (MC) and color customization in linux

Midnight Commander (MC) is a free and open-source file manager that provides a text-based user interface. It is available on numerous Unix-like systems, including Linux and macOS. It uses a two-panel layout, allowing users to view the contents of two directories simultaneously. This design makes it easy to move or copy files between directories. Due to its text-based user interface, MC functions exceptionally well on remote servers where graphical environments are unavailable, making it an indispensable tool for system administrators and developers.

How to change midnight commander colors

One of the main adjustments developers make while working with Midnight Commander is altering its interface colors. In this article, you’ll learn how you can tailor the colors to your own requirements 🙂

Choosing a color scheme from built-in options:

MC usually offers several skins from which you can select the one that suits you best. To do this:

Launch Midnight Commander. Start by opening the terminal and typing:
mc

Once MC is running:
Press F9 to access the main menu.
Select Options.
Then choose Appearance.
You will see a list of available color schemes. You can test each one by selecting it and pressing Enter.





Creating your own color scheme:

If you wish to craft your color scheme, open the file ~/.config/mc/ini in your preferred text editor, e.g., nano:
nano ~/.config/mc/ini
Locate the [Colors] section (or create it if it doesn’t exist) and define your color scheme. For instance:

base_color=normal=white,black:selected=gray,white:marked=yellow,blue:markselect=blue,yellow

These settings represent:
normal – text and background color (white text on a black background)
selected – color of highlighted text and background (gray text on white background)
marked – text and background color of a marked item (to mark an item use the Insert key) (yellow text on blue background)
markselect – text and background color of a highlighted marked item (blue text on yellow background)

You can use colors: black, gray, red, brightred, green, brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, cyan, brightcyan, lightgray, and white.
For more information about colors, type the following command in the console:
mc --help-color


After configuring your preferred colors, save the changes in the file (for nano, save as CTRL+O, to exit press CTRL+X).
Restart mc.


Crafting your color set in the form of a ‘skin’:

If you desire more flexibility in altering MC’s colors, you can create your custom skin.
For this, navigate to the directory ~/.local/share/mc/skins (or create it if it doesn’t exist) and generate your file, e.g., my_skin.ini.
Ensure the file has the appropriate write permissions:
chmod 644 ~/.local/share/mc/skins/my_skin.ini

Inside the my_skin.ini file, add color settings for various interface elements:

  • core,
  • menu,
  • dialog,
  • popupmenu,
  • error,
  • filehighlight,
  • buttonbar,
  • statusbar,
  • help,
  • editor,
  • viewer,
  • diffviewer.


Again, you can rely on the Midnight Commander color hints:
mc --help-color

This will display keywords you can utilize while setting your colors:
Keywords:
Global: errors, disabled, reverse, gauge, header
input, inputmark, inputunchanged, commandlinemark
bbarhotkey, bbarbutton, statusbar
File display: normal, selected, marked, markselect
Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,
errdhotfocus
Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive
Popup menus: pmenunormal, pmenusel, pmenutitle
Editor: editnormal, editbold, editmarked, editwhitespace,
editlinestate, editbg, editframe, editframeactive
editframedrag
Viewer: viewnormal, viewbold, viewunderline, viewselected
Help: helpnormal, helpitalic, helpbold, helplink, helpslink

For convenience, I’ve included the color settings file of my skin (primarily in black, white, and blue hues) along with the descriptions of each option:

#
#  JL skin
#

[skin]
    description = JL Skin
    256colors = false



[core]
    _default_ = white;default                           // text color (foreground/background)
    selected = white;blue                               // selected item color (foreground/background)
    marked = white;brightblue                           // marked item color (foreground/background) - Insert key
    markselect = black;blue;;bold                       // marked and selected item (foreground/background)
    gauge = white;blue                                  // progress bar colors
    input =  white;black                                // color of the text input areas
    inputmark = white;brightblue;bold                   // color of marked (or selected) text within an input area
    inputunchanged = blue;white                         // color of an input area that hasn't changed or been modified
    commandlinemark = white;brightblue;bold             // color of marked text within the command line specifically
    reverse = white;brightblue                          // color swap, where the foreground and background colors are switched
    header = white;black                                // header color (foreground/background)
    disabled = gray;lightgray
    errors = white;red                                  // errors colors (foreground/background)

[menu]
    _default_ = white;default                           // menu colors (foreground/background)
    menusel = white;blue;bold                           // focus menu element (foreground/background)
    menuhot = white;default                             // menu element dropdown colors (foreground/background)
    menuhotsel = white;black                            // menu text first letter color
    menuinactive = white                                // menu incative text color

[dialog]                                                // F9
    _default_ = white;blue                              // text color / bg color
    dhotnormal = black                                  // text first letter color
    dfocus = blue;white;bold                            // element focus colors (foreground/background)
    dhotfocus = blue;white                              // element dropdown colors (foreground/background)
    dtitle = white;;bold                                // dialog title color

[popupmenu]                                             // F2
    _default_ = white;blue                              // popup colors (foreground/background)
    menusel = blue;white;bold                           // popup focus colors (foreground/background)
    menutitle = white;;bold                             // popup title color

[error]
    _default_ = white;brightred                         // error message colors (foreground/background)
    errdfocus = red;white;bold                          // error element focus colors (foreground/background)
    errdhotnormal = black                               // error message text first letter color
    errdhotfocus = red;white                            // error element dropdown colors (foreground/background)
    errdtitle = white                                   // error title color

[filehighlight]                                         // set colors for different file types
    directory = blue;;bold                              // directory color
    executable = gray                                   // executable files
    symlink = yellow                                    // symlinks color
    hardlink = yellow                                   // hardlins color
    stalelink = yellow                                  // stalelinks color
    device = red                                        // e.g. hard drives, terminals, and other devices
    special = red                                       // e.g. socket files, named pipes (FIFOs), or block devices
    core = red
    temp = magenta                                      // temporary files
    archive = yellow                                    // archive files color
    doc = white                                        // documentation files that provide details, instructions, or other information, e.g .css, .json, .md files
    source = white                                     // source files
    media = white                                      // media files
    graph = gray                                       //
    database = red                                     // database files

[buttonbar]
    button = white;blue                                // color configuration for the entire button on the button bar (F1-10 Keys)
    hotkey = blue;;bold                                // color configuration for the hotkeys (highlighted shortcut keys) on the button bar

[statusbar]
   _default_ = black;white                             // color for the status bar in Midnight Commander.
                                                       // The status bar is usually found just above the command line input at the bottom of the interface.
                                                       // It provides contextual information, messages, or hints based on the current operation or selected item.

[help]
    _default_ = white;black                            // help text color (foreground/background)
    helpitalic = white;;italic                         // help italic text
    helpbold = blue;bold                               // help bold text
    helplink = blue;underline                          // help link color
    helpslink = blue;underline;bold                    // help current link style
    helptitle = white;;bold                            // help title color

[editor]
    _default_ = white;black                            // editor colors (foreground/background)
    editbold = white;;bold                             // color configuration for bold text within the editor
    editmarked = white;blue;bold                       // color of marked or selected text within the editor.
    editwhitespace = white;blue                        // color of whitespace characters, such as spaces or tabs
    editlinestate = black;white                        // color of line state indicators, often used to show if a line has been modified, especially in context with version control or differential comparisons

[viewer]
    _default_ = white;black                            // viewer colors (foreground/background)
    viewbold = ;;bold                                  // viewer bold text
    viewunderline = ;;underline                        // viewer underline text
    viewselected = white;blue;bold                     // viewer selected text

[diffviewer]
    changedline = white;brightblue                     // color of a line in the file that has been modified
    changednew = white;brightblue                      // color scheme for newly changed lines.
    changed = white;brightred                          // color scheme for newly removed lines
    added = black;brigtcyan                            // lines that are present in the new file/data but were not in the original
    removed = black;red                                // ines that were in the original file/data but are not in the new one
    error = white;red                                  // lines or sections where the diff viewer encountered an error or inconsistency that it couldn't resolve

[Lines]                                                // obramowanie paneli
    horiz = ─
    vert = │
    lefttop = ┌
    righttop = ┐
    leftbottom = └
    rightbottom = ┘
    topmiddle = ┬
    bottommiddle = ┴
    leftmiddle = ├
    rightmiddle = ┤
    cross = ┼
    dhoriz = ─
    dvert = │
    dlefttop = ┌
    drighttop = ┐
    dleftbottom = └
    drightbottom = ┘
    dtopmiddle = ─
    dbottommiddle = ─
    dleftmiddle = ├
    drightmiddle = ┤

My skin look like this:


Color customization in Midnight Commander allows you to customize its appearance, which can increase efficiency and comfort of use. This is quite simple and intuitive process that can be handled even by less experienced developers. By modifying the configuration file or using the built-in menu, users can experiment with different color palettes and customizing MC to their own preferences. Regardless of whether you strive to improve readability or simply want to give the tool a more personal touch, with Midnight Commander you can easily set your preferred colors 🙂

Joanna

Leave a Reply

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