Shawn Mervin

zsh and bash

zsh is my interactive shell and bash is what most of my scripts run in, so a production deploy is one guarded command.

Visit zsh.orgAt the command line

What it is

zsh and bash are Unix shells: the programs that read the commands you type in a terminal and run them. Both can also run scripts, which turns a series of commands into one repeatable step. Bash is the GNU Project's shell and the default on most Linux servers, including Ubuntu.

zsh is largely compatible with bash but adds better completion, globbing and prompt customisation, and it has been the default shell on macOS since Catalina. In practice many people use zsh at their desk and write bash scripts for servers, because bash is almost always installed on the other end.

How I use it

  • Most of my day happens in a terminal: servers, deploys, databases, DNS, the AWS accounts, app builds and the AI agents.
  • My production deploy scripts refuse to run from an unpushed branch or a dirty tree.
  • The deploy script for the stucco company's job app is locked, so two deploys never interleave, and it verifies the result with md5.
  • The AI agents I work with run in the terminal next to me, under the same scripts and the same rules.

A shell script is the right tool when a task has to be done the same way every time and the steps are commands you would type anyway. I reach for it because anything I do twice becomes a script with its own safety checks, so nothing depends on remembering which buttons to click or which order to run things in.

Questions

Why script deploys instead of running commands by hand?

A script does the same thing every time and can check its own preconditions first. Mine refuse to deploy from a branch that is not pushed or a working tree with uncommitted changes.

Do you write scripts in zsh or bash?

I work in zsh at the terminal and write most scripts so they run in bash, since bash is the shell on the Ubuntu servers they talk to.

Working with zsh and bash?

Tell me what you're building. Start a project or see the whole stack.

Got an operation that's outgrown its spreadsheets?

Tell me what your business does and where it's jamming up. If I'm not the right person for it, I'll say so and point you somewhere better.

What to send, and what happens next