omz-pnpm

July 7, 2026 · View on GitHub

An oh-my-zsh plugin for pnpm. Two jobs:

  1. A small set of aliases for the commands you actually type.
  2. Completion that includes package.json scripts. The official pnpm install-completion zsh script wires up pnpm completion-server, which handles built-in subcommands and flags but doesn't offer scripts at the bare pnpm <TAB> prompt and doesn't show script bodies as descriptions. This plugin layers both on top.

Install

git clone https://github.com/bgowers/omz-pnpm "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/pnpm"

Then add pnpm to the plugins=( … ) array in ~/.zshrc and start a new shell. If you previously ran pnpm install-completion zsh, remove the source …completion-for-pnpm.zsh line — this plugin replaces it.

Aliases

AliasExpands toNotes
ppnpm
pipnpm installMatches npm i. (pnpm i is also built-in.)
papnpm add
padpnpm add --save-dev
prmpnpm remove
prpnpm run
pdpnpm devpnpm forwards unmatched first args to scripts.
pbpnpm build
ptpnpm test
pfpnpm --filterFor workspaces. Append the package selector + command.
pdlxpnpm dlx
pexpnpm exec

Completion

  • pnpm <TAB> — built-in subcommands and package.json scripts.
  • pnpm run <TAB> — package.json scripts, with the script body shown as the description (e.g. dev next dev).
  • pnpm remove <TAB> (and rm / uninstall / un) — packages currently listed in dependencies, devDependencies, peerDependencies, or optionalDependencies.
  • Everything else — flags, install options, etc. — falls through to the official pnpm completion-server.

The package.json is found by walking up from the current directory, so it works the same whether you're at the repo root or three levels deep.

How it works

pnpm install-completion zsh writes a small wrapper that calls pnpm completion-server over the tabtab protocol. The plugin's _pnpm function does the same call, but then:

  • merges in package.json scripts at the bare-pnpm position (so pnpm de<TAB>dev),
  • replaces the server's script list at pnpm run with one that includes command bodies as descriptions,
  • adds an installed-packages list for pnpm remove.

It uses jq if available, falling back to node. Both produce the same output; jq is faster.

License

MIT