Midnight Commander is a CUI file manager which can be used via SSH.
This article will describe installing and usage Midnight Commander.
Table of Contents
1 Midnight Commander
There are many GUI file managers like Explore of Windows, Finder of OSX and Nautilus of Ubuntu.
Midnight Commander is a CUI file manager. You can use Midnight Commander on console without mouse operation (mouse operation can be used) and can use via SSH.
2 Install Midnight Commander
Install with apt, yum and homebrew.
$ sudo apt-get install -y mc
Run mc command.
$ mc
3 Configuration
Configuration files is saved at ${HOME}/.config/mc directory. Press 'F9' and focus menu.
3.1 Change skin
In case of terminal like xterm-256color, default skin is not good visual.
I recommend modarcon16 which has simple colors.
You can change skin at below menu.
Options -> Appearance -> Skin -> modarcon16
CentOS 7 does not have modarcon16, you need to download modarcon16.ini from internet.
$ wget https://raw.githubusercontent.com/MidnightCommander/mc/master/misc/skins/modarcon16.ini $ sudo cp modarcon16.ini /usr/share/mc/skins/
If modarcon16 is not displayed in Appearance menu, you need to append "skin=modarcon16" to ${HOME}/.config/mc/ini after first mc running. ${HOME}/.config/mc/ini will be created after first mc running.
$ grep "skin" ~/.config/mc/ini skin=modarcon16
3.2 Panel split
Split panel to vertical or horizontal.
Options -> Layout -> Panel split
3.3 Change panel content
Both panel content are File listing by default. Change one panel content to Quick View.
Above -> File lisint / Quick View Below -> File lisint / Quick View
Save configuration.
Options -> Save setup
3.4 Use external Editor and Viewer
Export EDITOR and VIEWER variable in ${HOME}/.bashrc.
$ export EDITOR=emacs $ export VIEWER=less
Uncheck "Use internal edit" and "Use internal view".
Options -> Configuration -> Other options -> Use internal edit / view
EDITOR will be run with 'F4' and VIEWER with 'F3'.
3.5 Change View/Edit/Open for not registered file type
Midnight Commander has View/Edit/Open action for each file. 'RET' is easy to push, so Open action is important.
key | action |
---|---|
F3 | View |
F4 | Edit |
RET | Open |
Open provies running shell script for *.sh and extracting zip file for *.zip file type.
Midnight commander does nothing for not registered file type. For make Midnight commander to do something for not registered file type, you need to create ${HOME}/.config/mc/mc.ext file with "Edit extension file" menu.
Command -> Edit extension file
Change Open and View at default/* for not registered file.
diff -uprN ~/.config/mc/mc.ext{.org,} --- /Users/hiroom2/.config/mc/mc.ext.org 2015-09-06 17:00:34.000000000 +0900 +++ /Users/hiroom2/.config/mc/mc.ext 2015-09-06 17:12:12.000000000 +0900 @@ -744,8 +744,8 @@ type/^Parity\ Archive\ Volume\ Set # Default target for anything not described above default/* - Open= - View= + Open=${EDITOR} %f + View=${VIEWER} %f ### EOF ###
4 Operation
4.1 Cursor operation
Cursor operation like emacs.
C-p | Move upper |
C-n | Move lower |
M-v | Scroll upper |
C-v | Scroll lower |
M-< | Move to the head |
M-> | Move to the tail |
4.2 Switch panel
Pressing 'TAB' switches panel.
Switched panel can be cursor operation.
4.3 File operation
There is no shortcut for creating file. Run "touch <filename>" on subshell for creating file.
'C-x' 'q' | less | Quick view |
'C-x' 'i' | ls | File attribute view |
'C-x' 'o' | chown | Change owner and group |
'C-x' 'c' | chmod | Change exec/read/write |
'F5' | cp | Copy file |
'F6' | mv | Move file |
'F7' | mkdir | Create directory |
'F8' | rm | Remove file / directory |
4.4 subshell
Typing keybord at file manager can run command at file manager.
'M-TAB' provides filename completion. 'M-h' provides command history.
You can switch file manager and subshell with 'C-o'.
You can operate in subshell same as normal shell.
4.5 Exit Midnight Manager
Press 'F10' or run exit command.
4.6 Combination Midnight Commander with GNU Screen 4.1 under UTF-8
You need to append "cjkwidth off" to ${HOME}/.screenrc.