Command line interface Icon

Command line interface

A CLI, or command-line interface, is a console that helps users issue commands to a program.
95 Stories
All Topics


google/zx – a tool for writing better scripts

Bash is great, but when it comes to writing scripts, people usually choose a more convenient programming language. JavaScript is a perfect choice, but standard Node.js library requires additional hassle before using. zx package provides useful wrappers around child_process, escapes arguments and gives sensible defaults.

I wouldn’t say JavaScript is a perfect choice for this kind of scripting, but it’s definitely a suitable one (especially if it’s the language you already know well). Here’s what scripting looks like with zx:

#!/usr/bin/env zx

await $`cat package.json | grep name`

let branch = await $`git branch --show-current`
await $`dep deploy --branch=${branch}`

await Promise.all([
  $`sleep 1; echo 1`,
  $`sleep 2; echo 2`,
  $`sleep 3; echo 3`,

let name = 'foo bar'
await $`mkdir /tmp/${name}`

Top-level await sure makes things nicer. (Deno supports this out of the box, btw.)

Julia Evans

A tool to spy on your DNS queries

You can think of Julia Evans’ new dnspeep tool as similar to tcpdump but specifically for watching your machine’s DNS queries.

One thing I like about this tool is that it gives me a sense for what programs on my computer are using the Internet! For example, I found out that something on my computer is making requests to from time to time for some reason, probably to check I’m connected to the internet.

A friend of mine actually discovered using this tool that he had some corporate monitoring software installed on his computer from an old job that he’d forgotten to uninstall, so you might even find something you want to remove.

It also probably comes in handy when debugging those pesky “could it be DNS?” issues, but this might be a limitation on that front:

One thing this program doesn’t do is tell you which process made the DNS query, there’s a tool called dnssnoop I found that does that. It uses eBPF and it looks cool but I haven’t tried it.

Command line interface

fselect – find files with SQL-like queries

This doesn’t aim to entirely replace find and ls, but if you already know SQL (like many of us do), why not be able to leverage that knowledge for your more advanced file-finding needs? Here’s a couple of examples so you get the idea:

Find temporary or config files (full path and size):

fselect size, path from /home/user where name = '*.cfg' or name = '*.tmp'

Use aggregate functions:

fselect "MIN(size), MAX(size), AVG(size), SUM(size), COUNT(*) from /home/user/Downloads"

Find by date and time intervals:

fselect path from /home/user where modified gte 2017-05-01

Command line interface

A tool for generating regular expressions from user-provided test cases

grex is a library as well as a command-line utility that is meant to simplify the often complicated and tedious task of creating regular expressions. It does so by automatically generating a single regular expression from user-provided test cases. The resulting expression is guaranteed to match the test cases which it was generated from.

Unfortunately, the tool’s authors still think you need learn how to write regexes, even when grex works flawlessly (and I tend to agree with them).

Command line interface

Crush – a command line shell that is also a modern programming language

Crush is an attempt to make a traditional command line shell that is also a modern programming language. It has the features one would expect from a modern programming language like a type system, closures and lexical scoping, but with a syntax geared toward both batch and interactive shell usage.

Check out the overview of features right here.

Command line interface

A guide to help you write better CLIs

From the foreword:

Most people today don’t know what the command line is, much less why they would want to bother with it. As computing pioneer Alan Kay said in a 2017 interview, “Because people don’t understand what computing is about, they think they have it in the iPhone, and that illusion is as bad as the illusion that ‘Guitar Hero’ is the same as a real guitar.”

Off to a good start…

Inspired by traditional UNIX philosophy, driven by an interest in encouraging a more delightful and accessible CLI environment, and guided by our experiences as programmers, we decided it was time to revisit the best practices and design principles for building command-line programs.

Command line interface

cheat lets you access interactive cheatsheets from the CLI

It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember.

Let’s imagine a completely hypothetical world where it’s the umpteenth time you’ve used it, but you still can’t remember which flags to send to tar… so you run:

cheat tar

You’ll be greeted by:

# To extract an uncompressed archive:
tar -xvf '/path/to/foo.tar'

# To extract a .gz archive:
tar -xzvf '/path/to/foo.tgz'

# To create a .gz archive:
tar -czvf '/path/to/foo.tgz' '/path/to/foo/'

# To extract a .bz2 archive:
tar -xjvf '/path/to/foo.tgz'

# To create a .bz2 archive:
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'

The cheatsheets themselves are community-sourced.

Command line interface

An intuitive CLI for processing video (powered by ffmpeg)

ffmpeg is an incredibly powerful tool, but its many flags and options make it not the easiest thing to wield (especially if you use it just infrequently enough to forget the magic syntax you ginned up last time).

vdx makes ffmpeg more approachable for many of the common video processing operations you may need on a regular basis. Examples!

$ vdx '*.mov' --crop=360,640    # Crop to width 360, height 640
$ vdx '*.mov' --format=gif      # Convert to GIF
$ vdx '*.mov' --fps=12          # Change the frame rate to 12
$ vdx '*.mov' --no-audio        # Strip audio
$ vdx '*.mov' --resize=360,-1   # Resize to width 360, maintaining aspect ratio
$ vdx '*.mov' --reverse         # Reverse
$ vdx '*.mov' --rotate=90       # Rotate 90 degrees clockwise
$ vdx '*.mov' --speed=2         # Double the speed
$ vdx '*.mov' --trim=0:05,0:10  # Trim from time 0:05 to 0:10
$ vdx '*.mov' --volume=0.5      # Halve the volume


Firefox Reader View as a Linux CLI

Command line tool to extract the main content from a webpage, as done by the “Reader View” feature of most modern browsers. It’s intended to be used with terminal RSS readers, to make the articles more readable on web browsers such as lynx. The code is closely adapted from the Firefox version and the output is expected to be mostly equivalent.

I could see this fitting in nicely in a pipeline between curl and, well, lots of other commands.


Ruby one-liners cookbook

Ruby is my favorite tool for slightly-longer-than-one-liners, but I don’t often reach for it directly from the command line. This little cookbook might change my mind on that:

A shell utility like bash provides built-in commands and scripting features to make it easier to solve and automate various tasks. External *nix commands like grep, sed, awk, sort, find, parallel etc can be combined to work with each other. Depending upon your familiarity with those tools, you can either use ruby as a single replacement or complement them for specific use cases.


The GitHub CLI goes 1.0

If you haven’t given the new gh a look since they announced the beta earlier this year, a lot has changed:

Since we released the beta, users have created over 250,000 pull requests, performed over 350,000 merges, and created over 20,000 issues with GitHub CLI.

It’s available for all major operating systems and if your development workflow goes through GitHub you will undoubtedly save some time and typing by adopting it.


K9s makes K8s look gooood ✨

We’ve linked K9s up in the past, but I’ve been playing with it today and I just had to share it again. Gerhard has us up and running on LKE (more on that coming to the blog and podcast soon) so I’ve had a chance to kick the tires a bit.

I have no idea how any of this magic works, but I do know that I like it and I’m excited to learn more. Here’s a screen grab of its Pulses feature, which gives you an overview of your entire cluster.

K9s makes K8s look gooood ✨


A pure Rust implementation of Git with a CLI

gix is a command-line interface (CLI) to access git repositories. It’s written to optimize the
user-experience, and perform as good or better than the canonical implementation.

Furthermore it provides an easy and safe to use API in the form of various small crates for implementing your own tools in a breeze.

The author describes this as “idiomatic, modern, lean, fast, safe, & pure” but that was too many superlatives to put in the headline. It does look nice, though. I dig the libraries + CLI that leverages them approach. Demo video on Asciinema.

Patrick DeVivo

AskGit - query your git repo with SQL

Built in Go, askgit is an open source CLI and coming soon web interface (linked above). With this tool in your toolbox, you can mine your repo for info like commit count by author on each day of the week:

    count(*) AS commits,
    count(CASE WHEN strftime('%w',author_when)='0' THEN 1 END) AS sunday,
    count(CASE WHEN strftime('%w',author_when)='1' THEN 1 END) AS monday,
    count(CASE WHEN strftime('%w',author_when)='2' THEN 1 END) AS tuesday,
    count(CASE WHEN strftime('%w',author_when)='3' THEN 1 END) AS wednesday,
    count(CASE WHEN strftime('%w',author_when)='4' THEN 1 END) AS thursday,
    count(CASE WHEN strftime('%w',author_when)='5' THEN 1 END) AS friday,
    count(CASE WHEN strftime('%w',author_when)='6' THEN 1 END) AS saturday,
FROM commits GROUP BY author_email ORDER BY commits

The Changelog The Changelog #406

Making Windows Terminal awesome

Kayla Cinnamon, Program Manager at Microsoft for Windows Terminal, Console, Command Line, and Cascadia Code joined us to talk about the release of Windows Terminal 1.0 and the new Windows command-line experience. We talk about everything that went into rethinking the command line experience on Windows, the UX and UI design behind it all, the learnings of working in open source, and what’s to come for the Windows command line experience.

0:00 / 0:00