LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

zx

JavaScript toolchain for writing shell scripts

TLDR

Run a zx script file
$ zx [script.mjs]
copy
Run inline with npx
$ npx zx [script.mjs]
copy
Install the package
$ npm install -g zx
copy
Example script header and command execution:
$ #!/usr/bin/env zx
await $`git status`
const branch = await $`git branch --show-current`
copy

SYNOPSIS

zx [*options*] *script*

DESCRIPTION

zx (from Google) makes writing complex shell scripts in JavaScript pleasant. It wraps Node's child_process with the $`cmd` tagged template for safe argument escaping, sensible defaults, and cross-platform behavior. Scripts can use async/await, Promise.all for parallel tasks, and the usual npm ecosystem.Works with Node.js, Bun, Deno, and similar runtimes. Documentation and setup variants (including a lite build) are at https://google.github.io/zx/.

PARAMETERS

*script*

Path to a .mjs/.js (or TypeScript when supported) script. Often starts with #!/usr/bin/env zx.
-h, --help / --version
Help and version (see zx --help for the installed CLI flags).
Inside scripts, the primary API is $`command` plus helpers documented upstream (cd, fetch, question, sleep, nothrow, etc.).

INSTALL

brew install zx
copy
nix profile install nixpkgs#zx
copy

CAVEATS

Not an officially supported Google product. Requires a JS runtime on PATH. Prefer quoting/escaping via $ templates rather than string concatenation to avoid injection. Behavior of the host shell still matters for complex pipelines.

SEE ALSO

node(1), bash(1), npm(1)

RESOURCES

Copied to clipboard
Kai