Midnight Commander - ArchWiki

# Midnight Commander

Related articles

- File manager functionality
- ranger

Midnight Commander is an orthodox (two-pane) file manager, supporting standard file operations, virtual filesystems, panelizing of external commands, and user menus. It also includes an internal viewer, editor, and visual diff tool.

As it is based on versatile text interfaces, such as Ncurses or S-Lang, it works on a regular console, inside an X Window terminal, over SSH connections and all kinds of remote shells.

## Installation

Install the mc package, or mc-gitAUR for the development version.

### Skins

- mc-solarized-git — Solarized color scheme for Midnight Commander

  https://github.com/nkulikov/mc-solarized-skin || mc-solarized-gitAUR

- mc-skin-candy — Candy color scheme (256color)

  candy256.ini ||

See also `Skins` in `man mc`.

## Usage

The below section provides a short overview on usage of Midnight commander. References to `man mc` and the Help function (`F1`, available in every dialog) are made in this article as `Section`.

Tip: All hints are available in `/usr/share/mc/hints/`.

### Interface

In prominent view are two vertical panes. Either can list directory contents, show a plain text preview, file details, or a directory tree (see `Directory Tree`). File operations are accessible through the function keys or the mouse. More options are visible in a dynamic user menu (`F2`) and option menu (`F9`). Keys above `F12` (`F13` up to `F20`) are accessible through `Shift`. Menu and dialog options have one letter highlighted - pressing this letter (or `Alt+Letter` inside a text entry) directly activates the respective option.

Below, a command line is visible, connected to a subshell. This shell is generally of the same type mc was launched from, and may be switched to at will (`Ctrl-O`), see `The subshell support`. On this command line, cd is interpreted by Midnight Commander, and not passed to the shell for execution. As such, special completion (such as from Zsh) is unavailable. Files in the pane interact with the command line; for example, `Alt+Enter` copies the name of a (selected) file to the command line.

Keybindings are generally similar to GNU Emacs. A more strict emacs keymap can be enabled (see `Redefine hotkey bindings`). New users may however use Lynx-like (arrow) keybindings (enabled in `F9 > Options > Panel options`) and mouse clicks for navigation.

### Modules

These can be called via the mc interface (with Use internal enabled in `F9 > Options > Configuration`), or separately as symbolic links to the mc binary.

- mcedit - Text and binary file editor, with regex replace, syntax highlighting, macros and shell piping, see `man mcedit`
- mcview - Text and hex viewer with goto marks and regex search
- mcdiff - Compares and edits two files in-place (`C-x d`)

Per `mc` instance, multiple modules can be run concurrently (`Ctrl-``) (see `Screen selector`). External editors may be used instead, and parameters configured accordingly.

## Configuration

Most of the Midnight Commander settings can be changed from the menus. However, a small number of settings such as clipboard commands, codeset detection and parameters for external editors can only be changed from `~/.config/mc/ini`. See `Special Settings` and following for a complete description of options.

Additionally, the following environment variables are respected: `MC_SKIN`, `MC_KEYMAP`, `MC_XDG_OPEN`, `MC_COLOR_TABLE`, `MC_DATADIR`, `MC_HOME`, `KEYBOARD_KEY_TIMEOUT_US`, `PAGER`, `EDITOR`, `VIEWER`.

See also `Files`.

### extfs

extfs allows to easily create new virtual filesystems for mc. See `/usr/lib/mc/extfs.d/README` for details.

## Tips and tricks

### Start from the menu

Midnight commander can be run from a menu with the correct Desktop entry. For example:

    [Desktop Entry]
    Type=Application
    Version=1.0
    Name=Midnight Commander
    Comment=Visual file manager
    Exec=mc
    Icon=folder
    MimeType=inode/directory
    Terminal=true
    Categories=Utility;

### Trash support

Midnight Commander does not support a trash can by default.

#### Using libtrash

Install the libtrashAUR package, and create an mc alias in the initialization file of your shell (e.g., `~/.bashrc` or `~/.zshrc`):

    alias mc='LD_PRELOAD=/usr/lib/libtrash.so.3.3 mc'

To apply the changes, reopen your shell session or `source` the shell initialization file.

Default settings are defined in `/etc/libtrash.conf.sys`. You can overwrite these settings per-user in `~/.libtrash`, for example:

    TRASH_CAN = .Trash
    INTERCEPT_RENAME = NO
    IGNORE_EXTENSIONS= o;exe;com
    UNCOVER_DIRS=/dev

Now files deleted by Midnight Commander (launched with mc) will be moved to the `~/.Trash` directory.

Warning:

- Applications launched from mc inherit `LD_PRELOAD`, which may cause problems with some applications. [1]
- With `GLOBAL_PROTECTION = YES` set (default), files deleted outside the home directory are moved to the trash, even if they are on a different partition. Depending on the file, this may cause a significant delay.

See also [2].

## Troubleshooting

### Exit to the current directory

This article or section needs expansion.

Reason: Check how to get mc-wrapper.sh working (Discuss in Talk:mc#Wrapper)

On exit, the shell returns to the directory Midnight Commander was started from, instead of the last active directory. A simple workaround is to switch to the subshell (`Ctrl+o`). This may however interfere with other terminal applications.

### Garbled screen

Press `Ctrl+l` to redraw the display. This only redraws, but does not refresh (`Ctrl+r`) the file list.

### Opening files

mc uses xdg-open to open files by default, as shown in `/usr/lib/mc/ext.d/`. While stderr is redirected, stdout is not, which may result in a garbled screen.

    /usr/lib/mc/ext.d/*.sh

    [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
    ...
    open)
        "${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" 2>/dev/null || \
            do_open_action "${filetype}"

Create a script to wrap xdg-open:

    ~/bin/xdg-open-null

    #!/bin/bash
    xdg-open "$@" >/dev/null

If mc is blocked until xdg-open ends, detach the process:

    ~/bin/xdg-open-null

    #!/bin/bash
    nohup xdg-open "$@" >/dev/null &

and make mc aware of it by setting the `MC_XDG_OPEN` environment variable:

    export MC_XDG_OPEN=~/bin/xdg-open-null

Tip: When #Using libtrash, add `unset LD_PRELOAD` before xdg-open in the script.

### Find file shows no results

If the Find file dialog (accessible with `Alt+?`) shows no results, check the current directory for symbolic links. Find file does not follow symbolic links, so use bind mounts (see `man mount`) instead, or the External panelize command.

## See also

- man mc(1)
- Draft of documentation

Category:

- File managers