Midnight Commander - ArchWiki

Jump to content

# Midnight Commander

4 languages

- Deutsch
- 日本語
- Русский
- 中文（简体）

From ArchWiki

Related articles

- File manager functionality
- lf
- nnn
- ranger
- Vifm

Midnight Commander is a visual shell for Unix-like systems. It 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 mcview(1), editor mcedit(1), and visual diff tool mcdiff(1).

As it is based on versatile text interfaces — ncurses or S-Lang — it works on a regular console, inside an X Window terminal, over Secure Shell (SSH) connections, and all kinds of remote shells.

The documentation[dead link 2025-03-15—HTTP 404] is still in draft state though.

## Installation

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

### Skins

Midnight Commander comes with multiple skins by default. You can set the skin in Options > Appearance.

Additional third-party skins can be installed separately:

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

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

- mc-skin-modarin-debian — Thin versions of the modarin theme.

  https://launchpad.net/debian/+source/mc/3:4.8.13-3 || mc-skin-modarin-debianAUR

See also mc(1) § Skins.

## 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 mc(1) § 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 mc(1) § FILES.

### extfs

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

## Usage

### 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 mc(1) § 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 Midnight Commander was launched from, and may be switched to at will (`Ctrl+o`), see mc(1) § 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 mc(1) § Redefine hotkey bindings). New users may however use Lynx-like (arrow) keybindings (enabled in Options > Panel options) and mouse clicks for navigation.

Mouse support for Linux virtual consoles can be enabled with General purpose mouse.

### Modules

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

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

Per Midnight Commander instance, multiple modules can be run concurrently and you can switch between them using `Alt+``, see mc(1) § Screen selector. External editors may be used instead, and parameters configured accordingly.

## 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 mc'

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

Default settings are defined in `/etc/libtrash.conf.sys`; the default trash directory is `~/Trash/`. You can overwrite these settings per-user in `~/.libtrash`, for example:

    ~/.libtrash

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

Now files deleted by Midnight Commander will be moved to the `~/.Trash/` directory.

Warning:

- Applications launched from Midnight Commander 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 this thread on the GNOME mailing list.

### mcedit syntax highlighting

The mcedit(1) § SYNTAX HIGHLIGHTING section lacks some essential information from the corresponding section of `man 1 cooledit`. Read both mcedit and cooledit manual pages, or apply the patch.

## Troubleshooting

### Exit to the current directory

On exit, the shell returns to the directory Midnight Commander was started from, instead of the last active directory. A wrapper script is included, which can be used by adding this line to your `~/.bashrc` or `~/.zshrc`:

    alias mc=". /usr/lib/mc/mc-wrapper.sh"

For the fish shell use this wrapper: http://mc-wrapper.fish. Place it to `~/.config/fish/functions/mc.fish` or execute the content inside `fish` shell and than run

    funcsave mc

Another simple workaround is to use 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

Midnight Commander reads the `MC_XDG_OPEN` environment variable to open files, which defaults to xdg-open when unset.

If Midnight Commander is blocked until the resulting process ends, or the process exits together with mc, use `nohup &`:

    ~/bin/nohup-open

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

And set `MC_XDG_OPEN` accordingly:

    $ export MC_XDG_OPEN=~/bin/nohup-open

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+?`, or `Esc+?`, or the F9 (menu) > Command > Find file) shows no results, check the current directory for symbolic links. Find file does not follow symbolic links, so use bind mounts (see mount(8)) instead, or the External panelize command.

### Broken shortcuts

With certain terminal definitions such as `screen-256color` or `xterm-termite`, shortcuts such as `Shift+F6` may not work or act as different combinations. To remedy this, assign the terminal sequences manually with the Learn keys dialog.

Settings will be stored in the `~/.config/mc/ini` file, for example for `screen-256color`:

Note: The following example assumes `F13`–`F20` are bound to `Shift+F3`–`Shift+F10`.

    [terminal:screen-256color]
    f1=\\eOP
    f2=\\eOQ
    f3=\\eOR
    f4=\\eOS
    f5=\\e[15~
    f6=\\e[17~
    f7=\\e[18~
    f8=\\e[19~
    f9=\\e[20~
    f10=\\e[21~
    f11=\\e[23~
    f12=\\e[24~
    f13=\\e[1\;2R
    f14=\\e[1\;2S
    f15=\\e[15\;2~
    f16=\\e[17\;2~
    f17=\\e[18\;2~
    f18=\\e[19\;2~
    f19=\\e[20\;2~
    f20=\\e[21\;2~
    complete=\\e^i
    backtab=\\e[Z
    backspace=^?

### Xterm window title customization

Xterm window title format is hardcoded to `mc [username@hostname]:current/path`, also see the corresponding ticket.

mc(1) § Screen selector (Screen list) file manager (Panels:) entry format is hardcoded too.

mcdiff(1), mcedit(1) and mcview(1) do not change Xterm window title at all.

Categories:

- File managers
- Console applications

Hidden category:

- Pages with dead links