Difference between revisions of "Main Page"

From wiki.samerhijazi.net
Jump to navigation Jump to search
(Replaced content with "Main Page")
(Tag: Replaced)
Line 1: Line 1:
[[Category:File managers]]
+
Main Page
[[Category:Console applications]]
 
[[fr:Midnight Commander]]
 
[[ja:Midnight Commander]]
 
[[ru:Midnight Commander]]
 
{{Related articles start}}
 
{{Related|File manager functionality}}
 
{{Related|ranger}}
 
{{Related articles end}}
 
 
 
[https://midnight-commander.org/ 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 {{Pkg|mc}} package, or {{AUR|mc-git}} 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:
 
 
 
* {{App|mc-solarized-git|Solarized color scheme for Midnight Commander|https://github.com/nkulikov/mc-solarized-skin|{{AUR|mc-solarized-git}}}}
 
* {{App|mc-skin-modarin-debian|Thin versions of the modarin theme|https://launchpad.net/debian/+source/mc/3:4.8.13-3|{{AUR|mc-skin-modarin-debian}}}}
 
 
 
See also {{man|1|mc|Skins}}.
 
 
 
== Usage ==
 
 
 
The below section provides a short overview on usage of Midnight commander.
 
 
 
{{Tip|All hints are available in {{ic|/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 {{man|1|mc|Directory Tree}}). File operations are accessible through the function keys or the mouse. More options are visible in a dynamic user menu ({{ic|F2}}) and option menu ({{ic|F9}}). Keys above {{ic|F12}} ({{ic|F13}} up to {{ic|F20}}) are accessible through {{ic|Shift}}. Menu and dialog options have one letter highlighted - pressing this letter (or {{ic|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 ({{ic|Ctrl-O}}), see {{man|1|mc|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, {{ic|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 {{man|1|mc|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 ''mc'' interface (with ''Use internal'' enabled in ''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|1|mcedit}}
 
* ''mcview'' - Text and hex viewer with goto marks and regex search
 
* ''mcdiff'' - Compares and edits two files in-place ({{ic|C-x d}})
 
 
 
Per {{ic|mc}} instance, multiple modules can be run concurrently ({{ic|Ctrl-`}}) (see {{man|1|mc|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 {{ic|~/.config/mc/ini}}. See {{man|1|mc|Special Settings}} and following for a complete description of options.
 
 
 
Additionally, the following environment variables are respected:
 
{{ic|MC_SKIN}}, {{ic|MC_KEYMAP}}, {{ic|MC_XDG_OPEN}}, {{ic|MC_COLOR_TABLE}}, {{ic|MC_DATADIR}}, {{ic|MC_HOME}}, {{ic|KEYBOARD_KEY_TIMEOUT_US}}, {{ic|PAGER}}, {{ic|EDITOR}}, {{ic|VIEWER}}.
 
 
 
See also {{man|1|mc|FILES}}.
 
 
 
=== extfs ===
 
 
 
extfs allows to easily create new virtual filesystems for mc. See {{ic|/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 [https://midnight-commander.org/ticket/3072 not support] a trash can by default.
 
 
 
==== Using libtrash ====
 
 
 
Install the {{Aur|libtrash}} package, and create an ''mc'' alias in the initialization file of your shell (e.g., {{ic|~/.bashrc}} or {{ic|~/.zshrc}}):
 
 
 
alias mc='LD_PRELOAD=/usr/lib/libtrash.so.3.3 mc'
 
 
 
To apply the changes, reopen your shell session or {{ic|source}} the shell initialization file.
 
 
 
Default settings are defined in {{ic|/etc/libtrash.conf.sys}}. You can overwrite these settings per-user in {{ic|~/.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 {{ic|~/.Trash}} directory.
 
 
 
{{Warning|
 
* Applications launched from ''mc'' inherit {{ic|LD_PRELOAD}}, which may cause problems with some applications. [http://pages.stern.nyu.edu/~marriaga/software/libtrash/]
 
* With {{ic|1=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 [https://mail.gnome.org/archives/mc/2010-March/msg00041.html].
 
 
 
== 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 {{ic|~/.bashrc}} or {{ic|~/.zshrc}}:
 
 
 
source /usr/lib/mc/mc.sh
 
 
 
This will alias {{ic|mc}} to the wrapper script.
 
 
 
Another simple workaround is to use the subshell ({{ic|Ctrl+o}}). This may however interfere with other terminal applications.
 
 
 
=== Garbled screen ===
 
 
 
Press {{ic|Ctrl+l}} to redraw the display. This only redraws, but does not refresh ({{ic|Ctrl+r}}) the file list.
 
 
 
=== Opening files ===
 
 
 
''mc'' reads the {{ic|MC_XDG_OPEN}} [[environment variable]] to open files, which defaults to [[xdg-open]] when unset. [https://github.com/MidnightCommander/mc/blob/master/misc/ext.d/misc.sh.in]
 
 
 
if ''mc'' is blocked until the resulting process ends, or the process exits together with mc, use {{ic|nohup &}}:
 
 
 
{{hc|~/bin/nohup-open|
 
#!/bin/bash
 
'''nohup''' xdg-open "$@" '''&'''
 
}}
 
 
 
and set {{ic|MC_XDG_OPEN}} accordingly:
 
 
 
export MC_XDG_OPEN=~/bin/nohup-open
 
 
 
{{Tip|When [[#Using libtrash]], add {{ic|unset LD_PRELOAD}} before ''xdg-open'' in the script.}}
 
 
 
=== Find file shows no results ===
 
 
 
If the ''Find file'' dialog (accessible with {{ic|Alt+?}}) shows no results, check the current directory for symbolic links. ''Find file'' does not follow symbolic links, so use bind mounts (see {{man|8|mount}}) instead, or the ''External panelize'' command.
 
 
 
=== Broken shortcuts ===
 
 
 
With certain terminal definitions such as {{ic|screen-256color}} or {{ic|xterm-termite}}, shortcuts such as {{ic|Shift+F6}} may not work or act as different combinations. To remedy his, assign the terminal sequences manually with the {{ic|'''Learn keys'''}} dialog.
 
 
 
Settings will be stored in the {{ic|~/.config/mc/ini}} file, for example for {{ic|screen-256color}}:
 
 
 
{{Note|The following example assumes {{ic|F13}}–{{ic|F20}} are bound to {{ic|Shift+F3}}–{{ic|Shift+F10}}.}}
 
 
 
{{bc|1=
 
[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=^?
 
}}
 
 
 
=== No bold text in urxvt ===
 
 
 
If started under [[urxvt]] with the default {{ic|TERM}} setting, text that is usually bold in many other terminals will not appear so. The root of the issue is because xterm couples bright text color with the bold attribute (thus, bright colors will always appear as bold in xterm).
 
 
 
urxvt does not have this limitation, which Slang (the library mc uses for text display by default) honors. Because Slang can decouple the bold attribute from bright colors on urxvt, mc would need to explicitly specify the bold attribute as appropriate ([https://bugzilla.redhat.com/show_bug.cgi?id=474108#c3 which it does not]).
 
 
 
The solution is to configure mc to explicitly use bold colors as desired, e.g. by editing the default skin as follows:
 
 
 
$ mkdir ~/.local/share/mc/skins
 
$ cp /usr/share/mc/skins/default.ini ~/.local/share/mc/skins/
 
$ sed -i -E 's/^(.* = (gray|brightred|brightgreen|yellow|brightblue|brightmagenta|brightcyan|white);.*)$/\0;bold/' ~/.local/share/mc/skins/default.ini
 
 
 
The above will create a copy of the default skin, but with all bright colors having an explicit bold attribute added.
 
 
 
Another common workaround is to set {{ic|1=TERM=xterm}}, however this causes other issues due to mismatching termcap/terminfo, such as certain keys not working.
 
 
 
== See also ==
 
 
 
* {{man|1|mc}}
 
* [https://midnight-commander.org/wiki/doc Draft of documentation]
 

Revision as of 00:34, 10 April 2019

Main Page