# zx

> JavaScript/TypeScript library and runner that wraps child_process with a $`...` template tag for writing cross-platform shell scripts with escaped arguments.

Stars: 45.8k · Language: JavaScript · License: Apache-2.0 · Categories: Shell

- Repository: https://github.com/google/zx
- Website: https://google.github.io/zx/
- Page: https://www.trmn.sh/tools/zx

## Install

- npm: `npm install zx`

## Overview

zx is a scripting tool that provides cross-platform wrappers around Node.js `child_process`. Scripts use the `$` template tag to run commands, for example await $`git branch --show-current`. Interpolated values are escaped automatically, so a variable such as 'foo bar' can be passed into `mkdir /tmp/${name}` safely. The package also sets sensible defaults for process execution.

Scripts can start with a `#!/usr/bin/env zx` shebang and are written in JavaScript or TypeScript. Because commands return promises, standard JavaScript constructs work with them, such as `await` for sequencing and `Promise.all` for running several commands in parallel. Command output can be stored in variables and passed to later commands, as in the README's branch-name deploy example.

zx runs on Linux, macOS and Windows. It supports Node.js 12.17.0 or later, Bun 1.0.0 or later, Deno 1.x and 2.x, and GraalVM Node.js. It works with Bash or PowerShell as the underlying shell and supports both CJS and ESM modules. A reduced variant, zx@lite, is documented separately. It suits developers and DevOps engineers who want to replace complex Bash scripts with JavaScript or TypeScript.

### Installation

```bash
# via npm
npm install zx
```

## Alternatives

- [Nushell](https://www.trmn.sh/tools/nushell.md): Structured data shell that treats commands and files as typed data rather than raw text streams (Rust, 40.7k stars)
- [zoxide](https://www.trmn.sh/tools/zoxide.md): Smart cd replacement that remembers frequently used directories for quick navigation (Rust, 40.3k stars)
- [Powerlevel10k](https://www.trmn.sh/tools/powerlevel10k.md): Zsh prompt theme with an interactive configuration wizard, instant prompt at shell startup, Git status segments, and Powerlevel9k config compatibility. (Shell, 55.3k stars)
- [zsh-autosuggestions](https://www.trmn.sh/tools/zsh-autosuggestions.md): Zsh plugin that shows inline command suggestions after the cursor, drawn from history and tab-completion, in the style of Fish. (Shell, 36.2k stars)
- [fish](https://www.trmn.sh/tools/fish.md): Interactive command line shell with syntax highlighting, autosuggestions, and tab completions that work without configuration (Rust, 34.4k stars)

---

Canonical: https://www.trmn.sh/tools/zx
