# omz-pnpm An oh-my-zsh plugin for [pnpm](https://pnpm.io). 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 ` prompt and doesn't show script bodies as descriptions. This plugin layers both on top. ## Install ```sh 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 | Alias | Expands to | Notes | | ----- | --------------------- | ------------------------------------------------------ | | `p` | `pnpm` | | | `pi` | `pnpm install` | Matches `npm i`. (`pnpm i` is also built-in.) | | `pa` | `pnpm add` | | | `pad` | `pnpm add --save-dev` | | | `prm` | `pnpm remove` | | | `pr` | `pnpm run` | | | `pd` | `pnpm dev` | pnpm forwards unmatched first args to scripts. | | `pb` | `pnpm build` | | | `pt` | `pnpm test` | | | `pf` | `pnpm --filter` | For workspaces. Append the package selector + command. | | `pdlx`| `pnpm dlx` | | | `pex` | `pnpm exec` | | ## Completion - `pnpm ` — built-in subcommands **and** package.json scripts. - `pnpm run ` — package.json scripts, with the script body shown as the description (e.g. `dev next dev`). - `pnpm remove ` (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](https://github.com/mklabs/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` → `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