Midnight Commander + iTerm (OS X) = bread and butter console tool

Midnight Commander (mc on your linux console) is a good case study for console mode applications. The GUI is not bad for manipulating filesystems in certain ways, but a competent mc jockey will smoke a gui-driver for almost any set of complex file manager tasks. If you add to that the fact that it supports mouse-interaction on an xterm, you have ‘the best of both worlds’.

Just a bit to get you started… type “mc [enter]”, and you’ll find yourself in a twin-paned console based world of blue screens hearkening back to Norton’s System Commander. If you just logged in, it will show you your home directory in two panels. Check and see if your [F1] key brings up help. If it doesn’t, you’ll need a bit of ancient Unix lore, which is this: Most console/terminal based application understand escape sequences for keystrokes. [esc]-1=[F1], [esc]-2=[F2]… [esc]-0=[F10]. The [esc]-1=[F1], etc. keystrokes are especially helpful under OS X / PowerBook because some function keys might be allready taken for exposure or other mac specific stuff.

mc has a ‘menu bar’ at the top, that you can access with [F9]/[esc]-9 and use the arrow keys to negotiate. It also has a ‘command bar’ at the bottom, listing the direct functions of the function keys. Both of these ‘bars’ respond to mouse commands if you have gpm ( GNU console mouse API ) or an XTERM with your TERM variable set properly (xterm, generically, eterm, aterm, rxvt, etc). [tab] will switch between screens for you, [ctrl-t] will mark and unmark files or directories to which you can apply the commands in the menus or on the command bar.
I often use OS X and since iTerm 0.8.2 there is added support of xterm mouse reporting allowing to use the mouse in mc even when you work on your Mac.

If you want to do something interesting to a file, like, say, grep it for something, you can position the cursor on the desired file and type “grep ‘some stuff’ [alt-enter]; this will copy the highlighted filename to the command line. On OS X I can’t make the alt key work this way and I figured out that [esc]-[enter] does work the same way. So on OS X you can use [esc] instead of [alt].
[alt-h]/[esc]-h will bring up a menu of command history. [alt-?]/[esc]-? brings up a ‘find’ dialog for finding files. [ctrl-\] brings up the ‘directory hotlist’ (think favorites in IE… nice tool. [alt-tab]/[esc]-tab does completion on the command line; hit it twice you get a menu of possible commands.

On top of all of that nifty stuff, it does ‘macro substitution’; this provides variables that you can use in command lines. For instance, ‘file %f [return]’ will run the command ‘file’ on the highlighted item in the panel. %x gets you the extension of the currently highlighted item, %b will give you the name of the current highlighted item without the extension, %d will give you the currently selected directory name, %t will give you the currently tagged files in a list… the list goes on. Great stuff for quickly doing lots of interesting stuff to collections of files.

There is also a user-editable popup menu under [F2]. You can hit [F2][@] and ‘do something with the current file’ – you’ll get a dialog asking for the command and parameters.

In the end, you can make mc an extremely productive file manager environment. Leave the image browsing to a graphical browser like Konqueror, Nautilus, Explorer or Finder but when you need to get some stuff done, mc may become your best friend!

2 comments Write a comment

  1. Thank u so much. I was already looking for some ssh client for mac where I could send the F10 key signal via menu. I tried all possible key combos that came to my mind, but never thought of Esc (well, it wasn’t that obvious to me). thanks again.