Shell Icon


A shell is a command-line tool, designed to be run by the Unix shell.
21 Stories
All Topics


Shell script best practices

An opinionated set of thumb rules that Shrikant Sharat Kandula follows after a decade of writing shell scripts. His starter template looks nice as well:

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
    set -o xtrace

if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
    echo 'Usage: ./ arg-one arg-two

This is an awesome bash script to make your life better.


cd "$(dirname "$0")"

main() {
    echo do awesome stuff

main "$@"


Shell productivity tips and tricks

This post is part of a sample chapter from Essential Tools and Practices for the Aspiring Software Developer — a self-published in-progress book by Balthazar Rouberol and Etienne Brodu.

I estimate that I spend around 50% of my day working in my text editor and my terminal. Any way I can get more productive in these environments has a direct and measurable impact on my daily productivity as a whole.

If you spend a good chunk of your day repeatedly hitting the left and right arrow keys to navigate in long commands or correct typos, or hitting the up or down arrow keys to navigate your command history, this chapter should help you get more done quicker. We will cover some shell features you can leverage to make your shell do more of the work for you.

On a personal level, I probably use some of these up to 30 times a day, sometimes even without thinking about it, and it gives me a real sense of ownership of my tool.


A fast `cd` command that learns your habits

zoxide keeps track of your most frequently used directories and uses a ranking algorithm to navigate to the best match. It was inspired by z and z.lua, but it’s written in Rust and out-performs both:

On my system, compiled with the x86_64-unknown-linux-musl target, hyperfine reports that zoxide runs 10-20x faster than z.lua, which, in turn, runs 3x faster than z. This is pretty significant, since this command runs once at every shell prompt, and any slowdown there will result in an increased loading time for every prompt.

Changelog Interviews Changelog Interviews #363

Nushell for the GitHub era

Jonathan Turner, Andrés Robalino, and Yehuda Katz joined the show to talk about Nushell, or just Nu for short. It’s a modern shell for the GitHub era. It’s written in Rust, and it has the backing of some of the greatest minds in open source. We talk through what it is, how it works and cool things you can do with it, why Rust, ideas for the future, and ways for the community to get involved and contribute.

Jessie Frazelle

For the love of pipes

Jessie Frazelle spells out why she loves the | command. Here’s the brief:

In brief, the | allows for the output of one program (on the left) to become the input of another program (on the right). It is a way of connecting two commands together.

Did you know pipes pre-dated Unix?! 1964! Lots of good stuff in this post, highly worth the click.

Safia Abdalla

What happens when you run `sudo !!`?

Safia Abdalla continues her excellent series of “what happens when” posts, this time tackling sudo !!:

One thing I’m sure everyone has done on the command line is to use the !! shortcut to run the command run previously with sudo.

Don’t be so sure, Safia. It took me literally years of command-lining around before I learned that trick. I bet you taught more than a few people about its existence with this very article. 👌

Player art
  0:00 / 0:00