CLI Tools

  1. f3: Fight Flash Fraud
  2. vite: Next generation frontend tooling
  1. Homebrew 4.0
  2. Mainframes are still a big thing
  3. Docker Compose: What’s New, What’s Changing, What’s Next

Tip of the Week

Using the GitHub CLI tool, gh, you can create and edit gists. However, to update a gist, you are required to open the file in your set editor. But we can get around this by using the VISUAL environment variable, and the tee program.

Part 1: EDITOR and VISUAL

In historical content, EDITOR would be a lightweight editor (e.g. ed) and VISUAL would be a full-fledged editor (e.g. vi). Nowadays, you can set them both to the same (e.g. vim, emacs), and you may even opt to set VISUAL to a GUI app (e.g. code for VSCode). The shell will open the appropriate program when applicable. Side note: this is similar for the PAGER variable as well, e.g. set it to bat instead of less.

Part 2: Piping with tee

The tee programs lets us split output, to stdout but also to a file. Some examples:

% date >&1  # a verbose way to show redirection to stdout
% date >&2  # redirection to stderr
% date > /tmp/date  # output to a file
% date >> /tmp/date  # append output to a file

% date | tee /tmp/date  # output to stdout _and_ a file
% date | tee -a /tmp/date  # stdout and append to a file

# pipe to stdout but also pipe to additional commands
% date +%F_%T | tee /dev/tty | tr -d ":-" | tr "_" "-"
2023-02-16_21:18:58
20230216-211858

Part 3: Putting it Together

Since gh supports VISUAL, we set it to tee so that reading in a file pipes the file contents into gh without ever opening an editor. The final > /dev/null sinkholes the file contents since we don’t need to actually see it in stdout.

VISUAL=tee gh gist edit GIST < /path/to/file > /dev/null