How to be cutting-edge and old-school in the Linux terminal

2018-08-10 @Technology

Linux facilitates heavy automation or optimization of frequently recurring tasks. For the most part, I employ terminal-based, also known as command-line interface (CLI) applications for this purpose. They offer numerous benefits:

A properly configured CLI workflow also carries the mechanical benefit of decreased hand movement - enabling you to largely maintain your hands on the alpha-numerical portion of the keyboard, without the chaotic shifts to the mouse or the more distant ancillary keys.

You can achieve significant leaps in productivity and speed in becoming accustomed to CLIs.

Here I survey the different categories of CLI applications I rely on.

Terminal-based File Managers

You can accomplish much via raw terminal commands for many file and directory navigation and manipulation tasks. In some cases, however, the interaction can become a nuisance for heavily repetitive operations not easily automated via a terminal. In such cases, I have used two among many terminal-based file managers: Midnight Commander and Ranger.

I have used Midnight Commander as early as 1995 on a DOS system, then titled Norton Commander. The traditional blue background and shortcut keys always felt familiar and yet lend to much customization.

Lately, however, I transitioned to Ranger, offering far more power and flexibility than MC, and configured for VIM-like navigation and shortcut keys by default. I would call Ranger a meta file manager even, since you can redefine much of the underlying behavior and interaction mechanism to your liking. I have optimized many of my most frequent operations, such as navigating to frequently used files and directories, remotely manipulating music listening, and copy/move/rename operations in a way far more efficient than traditionally provided by the raw terminal, MC, or especially a graphical file manager. You would have to experiment with it yourself to uncover the potential.

Session-based terminal managers

TMux and Screen are both terminal multiplexors and session managers, enabling you to split and manage your terminal sessions across windows and panes, search through the terminal buffer, but most importantly, maintain entire terminal sessions in memory. You are free to disconnect from a session, reconnect, and restore your entire terminal layout and workflow. Both session-managers are heavily configurable and shortcut-oriented. I operate almost exclusively in the confines of Tmux.

VIM and Emacs powerful text editing

I appeal almost exclusively to VIM for virtually anything requiring the editing of text: blog, notes, journal, presentations, rich documents, scripts, source code, email, calendar, configurations, and even the editing of a complex terminal command.

Emacs is an alternative all-in-one text editing ecosystem (plus a lot more). It’s somewhat heavier than VIM, though I cannot further comment without speculation, having never experimented with it. From the little I know, you can likely attain similar power usage from both, though the relative heaviness of Emacs always steered me towards VIM.

Each requires a moderate learning curve - perhaps a month or two to get accustomed to even a small portion of functionality. This, however, per the 80/20, will represent a large part of your needs.

A small subset of VIM’s immense power:

Console-based music players

Cmus is a console music player, while mpd is more of a daemon requiring a separate client. Both, however, provide essentially console-based music playing. I use the former.

Both can be configured to navigate across your multimedia library with ease of quick shortcuts, manipulate playback, and interface with other applications. I configured ranger, for example, to interact with cmus via 2-keystroke combinations, as well as add groups of selected multimedia files to the immediate playlist.

Text-based document creation

These tools enable rich document composition by means of plain text, freeing the task of content creation from the bonds of heavy word processors or interactive graphical environments.

Latex is a document typesetting system that, via combinations of internal and external modules can render any sort of PDF document by means of editing particular schema in plain text (via some text editor like VIM). The resulting document can contain mathematical symbology, complex diagrams, slide presentations, plots, tables, and effectively anything you’ve witnessed within a PDF document.

A severe portion of academic academic publications are actually composed via Latex, though it also sees less formal usage; Latex can produce an whole professionally typeset book ready for publishing, or a simple informal letter.

Similar to the VIM text editor, the Latex ecosystem can demand weeks to months to adapt (depending on your drive), but then produce a lifetime of dividends.

Pandoc

Pandoc is a system to convert between different markups or to compile a markup into a PDF (via Latex as an intermediary), among other visual formats. Compared to Latex, Markup is a far simpler and quicker to learn syntax for producing rich documents (including HTML). It delivers for most simpler cases (including web pages and presentation slides), though for anything greater, it cannot compete with a fully featured Latex schema and processor.

Asymptote

Asymptote, albeit less frequently used by me, is one among a number of alternatives to render vector-based graphics (ie a PNG image) by means of pure mathematical programming (using C-based syntax), though by far not everyone is inclined towards this mode of visual rendering. It also directly interfaces with Latex.

The advantage of text-based formats lies in the power to wield other text-manipulation mechanisms to generate or transform one syntax into any other. For instance, generate your own abstractions to transform simpler directives into the more complex, such as a simple parameterized directive into a complex vector-graphics routine.

Terminal-based email

Over the years I’ve interchanged between CLI email tools and web-based interfaces to the likes of Gmail. An alpine user over a number of years, I’d recently become interested in neomutt, a mutt variant, and primarily for the familiarity with VIM-like key bindings. In fact, VIM and Emacs represent such an integral asset to the Linux ecosystem that their signature keybindings have become adapted by swarms of other CLI applications involving an element of navigation or searching.

Now I’m not yet convinced that a terminal-based email client can lead to a strictly-speaking quicker workflow than a web-based interface such as Gmail, which, in fact, also features configurable key-bindings, albeit less known.

I am, however, convinced that with enough usage, it certainly does not compromise the workflow - a win, considering yet another operation divorced from graphical utilities (or web browsers) and heavier system requirements.

Cloud computing

If using major cloud providers, Google, Amazon, and Dropbox (among others) provide CLI tools for many of their principle products.

As an Amazon cloud user (per this posting), I frequently leverage the Amazon AWS CLI tools to 1) interact with the Amazon S3 storage cloud, and 2) manage the Amazon EC2 computing instances. The extent to which these can streamline your workflow is limited mostly to imagination.

Console web browsers

I use console-based web browsers sporadically, mostly out of occasional curiosity to the extent of how much web content I can outsource to the more limited-capacity text-based web browser engines. Despite years of such experiments with all the mentioned browsers here, I haven’t maintained enough consistence and refrain from further generalization. In fact, I wish to postpone such analysis for a different post, as I believe much intriguing utility can be extracted from proper application of these controversial tools.

Other powerful CLI tools

Sources referenced

  1. Midnight Commander
  2. Ranger
  3. TMux
  4. Screen
  5. VIM
  6. Emacs
  7. cmus
  8. mpd
  9. Latex
  10. Pandoc
  11. Asymptote
  12. quick generation of slides
  13. alpine
  14. neomutt
  15. Amazon AWS CLI
  16. w3m
  17. lynx
  18. links
  19. jrnl

Questions, comments? Connect.