i For Business Event Logo

Bookmark and Share
RSS

Recent Posts

All Hail the Midnight Commander!

November 27, 2018

Quite often, I’m asked how open source deliveries are prioritized at IBM. The answer isn’t simple. Even after we estimate the cost of a project, there are many factors to consider. For instance, does it enable a specific solution to run? Does it expand a programming language’s abilities? Is it highly-requested by the community or vendors?

Sometimes, though, a tool is just too fun to pass up; such is the case for Midnight Commander! Of course, we also had numerous requests for it, and that helped, too! Today, let’s explore this useful utility.

What (or who?) is the Midnight Commander?

The Midnight Commander website describes the tool as a visual file manager that is “a feature rich full-screen text mode application that allows you to copy, move and delete files and whole directory trees, search for files and run commands in the subshell. Internal viewer and editor are included.”

Sounds great, but maybe some screen shots would help. Midnight Commander’s default interface is a two-pane, side-by-side view. At first launch, you’ll see the current directory.

mc1.png

But, what if you don’t like blue? After all, perhaps you’re more accustomed to a black background. No problem! Midnight Commander comes with several skins for you to try (though note that 256-color skins don’t work on IBM i). To tinker, just go to “Appearance” under the “Options” menu. My favorite is called “darkfar,” shown here:

mc2.png

On that note, the overall interface is relatively intuitive. The menus (File, Command, etc.) behave similar to those of familiar GUI applications, and they can be driven by keyboard or mouse. Function keys perform actions. Need help? Just press F1! The mouse wheel even works!

Midnight Commander also supports a “subshell.” That allows you to run shell commands without leaving the Midnight Commander interface. You may notice a bash (shell) prompt at the bottom, and you can just run your commands there. In this crazy-simple demonstration, I’m just running the “echo” command:

mc3.png



mc4.png


You can, of course, traverse the filesystem by navigating in the filesystem view (again with either keyboard or mouse). There’s also a directory tree view, if you prefer (in the “Command” menu).

mc5.png

Also, what’s shown on the right or left panes can be customized through the “Right” and “Left” menus. For instance, you can show a directory tree on one side, or show the file attributes.

mc6.png

Heck, you can even open an FTP site on either side!

mc7.png


mc8.png

Yet another feature allows you to compare directories or files (after all, it’s a two-pane view). Using this tool, it’s easy to see differences. In this file comparison example, you can see that changes, additions, and deletions are colorized logically.

mc9.png

At this point, I feel as though I’m showing off, so I’ll leave the rest of Midnight Commander for you to explore on your own. This gizmo of an open source project has many more features. Surely, it’s useful for anyone digging around in stream files and directories.

Getting Started
Installing Midnight Commander is easy. Once you have the yum package manager, use it to install the ‘mc’ package.

In order for the interface to display properly, you’ll want to set the LC_ALL environment variable to a UTF-8 locale. For instance, “EN_US.UTF-8” would work just fine. You can have this done automatically by putting the following lines in your $HOME/.profile file (or $HOME/.bash_profile):

LC_ALL=EN_US.UTF-8
export LC_ALL

If you haven’t done so already, you might want to also make sure the PATH environment variable is set up to use the new open source tools.

Once that’s done, you can run ‘mc -c’ from your SSH terminal. (You didn’t expect this to work from QSH, did you?) If you didn’t set up your environment variables, you can just run ‘LC_ALL=EN_US.UTF-8 /QOpenSys/pkgs/bin/mc -c’ instead. I recommend the ‘-c’ option because it enables colors.

A Community Effort
As with many things open source, IBM was not the only contributor. In this particular case, a “tip of the hat” goes to Jack Woehr. You may remember Jack as the creator of Ublu, an open source programming language for IBM i. He also hosts his own RPM repository with lynx, a terminal-based web browser (perhaps a future topic?). The initial port of Midnight Commander was collaboratively done with work from both parties. Jack also helped with quality assurance and worked with project owners to upstream all code changes. In fact, the main code stream for Midnight Commander can now be built for IBM i with no modifications.

Now that we’ve delivered hundreds of open source packages, it seems like there’s something for everybody. This seems like one of those tools that is useful for just about anyone. And with a name like “Midnight Commander,” how can you go wrong? Try it today!

Posted November 27, 2018| Permalink

Post a Comment

Note: Comments are moderated and will not appear until approved

comments powered by Disqus