Midnight Commander

Midnight commander is one of the most mature software on Linux. This site explains mc in details. Many software developers spend most of their life while using mc (midnight commander).
Newcomers easily learn to use midnight commander and experts use its powerful features. It supports mouse but without mouse it works faster.

I am a solo developer. I use computer to:

  1. Write programmes for 8bit-avr micro-controllers in assembly language. That gives me complete control over the device.
  2. Develope applications for 8bit-avr, I use gnu-octave to handle numerical data.
  3. Confirm hardware designs, I use ngspice.
  4. Generate html (for publishing) and pdf (using latex) documents.

All the four tasks mentioned, need some sort of programming and scripting. There I need:

  • An editor,
  • A file manager,
  • A terminal to run commands.

These functions are very well supported in mc, making it an Integrated Development Environment (IDE).

The Editor

Midnight commander has a built-in editor: MCedit. A powerful editor that can handle text up to 64MB file size. I don’t expect to write such a big programme in assembly for an 8bit-avr ;-). However, other features of MCedit tempt me to use it. Some of the features are:

  1. Custom keybinding. I used to be an Emacs user! So I prefer Emacs keybindings. MCedit provides almost similar keybindings as one of many choices.
  2. Syntax highlight is another powerful feature. MCedit provides coloured syntax highlight for avr-assembly, octave, ngspice, html and latex. All five are useful to me. I love to see colours, they not only beautify the code but also detect, almost immediately, spelling errors in instruction mnemonics and keywords.
  3. Quick Navigation throughout the file is easily possible using keyboard shortcuts. e.g. Alt-l will ask you the line number and jump there. This helps immediately going to the code line where some error is detected.
  4. Multiple files can be kept open simultaneously: This helps to refer to relevant subroutines in different files at the same time.
  5. Visual bookmarks are very useful in navigating amongst important routines, functions.
  6. Features like keyboard macros, auto-complete words, spellcheck, help to increase the quality of the code in general.
  7. Editor menus help to customise and automate many features using scripts. Using this I insert assembly language template when starting a new project.
  8. Using keyboard macros I can quickly type repeated strings in a document.

The File Manager

Although the editor MCedit is most useful to me, midnight commander is more famous as a file manager. MCedit is a part of midnight commander and that makes it a powerful IDE. Here are some examples:

  • File manager menu is useful when I customise it to handle version control of my project.
  • Menu also can be customised to do repetitive tasks like assembling a source file.
  • It is easier to copy files from earlier project directories when applicable.
  • Pressing Alt-h allows us to choose from earlier commands. This is useful to assemble the main file of the project.
  • I edit circuit diagrams, using external software Xfig, just by pressing F2 key and x, because I have customised the menu to open Xfig software when I press F2-x. Customised menus is a powerful feature of mc.
  • Directory hot list feature is very useful to shift from one project to the other very quickly.

There will be more such examples because working with midnight commander is a continuous improvement process. I always learn something new while using midnight commander.

Access to Terminal/Console

This is a very important feature of midnight commander. I run MC in XTerm or in console. Pressing Ctrl-o anytime will toggle to and from the terminal/console. In addition to editing and file management, I need to run assembler, latex, calculator (e.g. wcalc) and even play games. Here are some examples when I temporarily toggle to console/XTerm from midnight commander:

  • Run calculator wcalc, and paste result in MCedit
  • Run octave and paste results in MCedit.
  • Run latex and create printable beautiful pdf documents
  • Run avrdude chip programming software.
  • Play games like tetris, boggle, hangman,…!

Running only one terminal application at a time is the only limitation. If the application is run as a background process, the limitation may vanish, but I have not tried it yet.

The only downside

Midnight commander’s support for utf-8 is not perfect, particularly for Devanagari script. MC depends upon the terminal properties for this. I tried running MC in Konsole, but in vain 🙁 . I have to use another gtk based editor mousepad using midnight commander menu, and I enjoy only the file manager and console facilities.
It is a gnu project, so I hope the development team will solve this problem in near future, I have enjoyed fast and friendly support from the MC developers’ community.


This entry was posted in SciTech. Bookmark the permalink.

Leave a Reply

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