UPDATE (23-May-2019): Added information about moreutils.
UPDATE (9-Jan-2019): Added information about exa, hyperfine, PathPicker, and svg-term-cli utilities.
UPDATE (19-Nov-2018): Added information about the Pipe Viewer utility.
People who use Unix since 1980s, or GNU/Linux since 1990s know that they can rely on the command line and many utilities for a lot of daily automation and data processing tasks. As someone who’s been using Unix and GNU/Linux based systems since 1994, I’m more than happy that I can count on these tools and the stable know-how built on them. Nevertheless, I think the command line and TUIs (Text-based User Interfaces) can be a bit better in 21. century. Therefore, in this post, I’ll list a few recent utilities that helps us to have a better command line experience.
Before you dive into the list, please be aware that I’m after the low-hanging fruit, that is, tools that can make an existing Unix / Linux command line environment a bit better with the least disruption. In other words, I will not touch on how to have brand new, GPU-powered terminal emulators such as alacritty and kitty, and neither will I talk about how nice it’d be if you only changed your shell from Bash into fish, or elvish. (If you really want to know about alternative shells, please read https://github.com/oilshell/oil/wiki/ExternalResources and http://www.oilshell.org/blog/2018/01/28.html.) I also won’t send you down the rabbit hole and make you spend countless hours customizing your shell prompt (that requires an article by itself, but in the meantime you can go and check Go Bullet Train (GBT), you’ve been warned!). Finally, no, I won’t be talking about
tmux, too, because it has books dedicated to it such as “The Tao of tmux” and “tmux 2: Productive Mouse-Free Development“.
If you think something is missing and fits within the context of “low-hanging fruit” (see above), please add a comment at the end of this post. Also, for a more specialized domain, see my recent post titled “Data Processing Resources: Command-line Interface (CLI) for CSV, TSV, JSON, and XML“.
So let’s start with
cd command, and how it can be enhanced with context and history, together with fuzzy matching:
Quickly finding files is also a very regular task, and we can always rely on the
find utility, but we can have a slightly more ergonomic version:
Whenever I need to use a command line program that I haven’t used for a while, I need to refresh my memory, and probably read at least one man page. But even for commands such as
tar, reading a man page can trigger a TL;DR (Too Long; Didn’t Read) reaction. Therefore, tealdeer to the rescue:
Another command that I frequently use is
cat, and it’s great that we can rely on an enhanced
– bat: A cat(1) clone with wings. I think this utility is good enough to move the official
cat to the attic and use in only rare circumstances.
Every now and then, I check how much disk space is left, or which directory is consuming the biggest amount. Back in the day, I used
du for this, and I also like the more interactive version that’s called ncdu, but nowadays I think the following tiny terminal file manager can also be used for that task:
– nnn: probably the fastest and most resource-sensitive file manager you have ever used. It integrates seamlessly with your DE and favourite GUI utilities, has a unique navigate-as-you-type mode with auto-select, disk usage analyzer mode, bookmarks, familiar navigation shortcuts, subshell spawning and much more. It also lets you preview a file using whichever previewer you want. You can use bat, or even emacsclient (that is, if you, like me, prefer to have your Emacs server started, first thing after booting).
One other frequent task, in addition to navigating around your directories, and files is searching for strings and patterns in them. You always have the venerable
grep tool, but nowadays, we have nice alternatives such as ripgrep:
Another tool that I and many other people use very frequently is Git, a version-control system for tracking changes in computer files. And when using Git, as well as other similar tools, seeing what changed in a particular file is important. Normally you rely on your favorite Git tool to compare two versions of a file, but if you need to quickly compare two files on the command line, independent of your Git tool, you can rely on:
Next in line, we have an alternative for the venerable
ping utility. I think having a bit more information from ping wouldn’t hurt:
– prettyping: runs the standard
ping in background and parses its output, showing ping responses in a graphical way at the terminal (by using colors and Unicode characters). It’s written in
awk, and should work out-of-the-box in most systems (Linux, BSD, Mac OS X, …). It is self-contained in only one file, so it is trivial to install and run. (You can also give gping a try).
Another relatively less known tool is
pv , the pipe viewer: it is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion:
One thing that I also do at the command line is to trigger an event whenever there’s some change to some files & directories. Of course, you can
watchfor things, and even utilize inotify subsystem, but maybe you’ll find the following more convenient to quickly build a command line event triggering system:
And finally, a few honorable mentions:
– exa: a modern replacement for ls. It’s an improved file lister with more features and better defaults. It uses colours to distinguish file types and metadata. It knows about symlinks, extended attributes, and Git. And it’s small, fast, and just one single binary. Source code is also available at https://github.com/ogham/exa.
– PathPicker: accepts a wide range of input — output from git commands, grep results, searches — pretty much anything.After parsing the input, PathPicker presents you with a nice UI to select which files you’re interested in. After that you can open them in your favorite editor or execute arbitrary commands.
– svg-term-cli: Share terminal sessions as razor-sharp animated SVG everywhere. Useful for demonstrations and information sharing, error-reporting, etc.
– moreutils: “a growing collection of the Unix tools that nobody thought to write long ago when Unix was young.” Once you get used to them, you’ll wonder how you managed to live without them.