Shell completion
The varlock CLI supports tab completion for subcommands and flags. There are two ways to get it, depending on how varlock is installed:
varlockon your PATH (standalone binary or global npm install): install varlock’s own completion script. See Setup below.- varlock as a local project dependency (run via
pnpm exec,npm exec,bun x, scripts, etc.): completion comes from your package manager’s completion instead. See Local project installs.
Use this when varlock is on your PATH, installed via the standalone binary (Homebrew or cURL) or a global npm install (npm install -g varlock).
Generate a completion script with varlock complete <shell>, then install it using the instructions below for your shell.
After upgrading varlock, re-run varlock complete <shell> if new commands or flags were added.
Zsh completion files must be named with a leading underscore:
mkdir -p ~/.zsh/completionsecho 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrcecho 'autoload -U compinit && compinit' >> ~/.zshrcvarlock complete zsh > ~/.zsh/completions/_varlocksource ~/.zshrcmkdir -p ~/.local/share/bash-completion/completionsvarlock complete bash > ~/.local/share/bash-completion/completions/varlocksource ~/.bashrcmkdir -p ~/.config/fish/completionsvarlock complete fish > ~/.config/fish/completions/varlock.fishFish loads completions automatically. Restart your shell or open a new terminal to pick them up.
varlock complete powershell >> $PROFILE. $PROFILELocal project installs
Section titled “Local project installs”When varlock is only a local dependency (not on your PATH), you run it through your package manager: pnpm exec varlock …, npm exec varlock …, bun x varlock …, or a package.json script. In that case completion comes from your package manager’s completion, which delegates to varlock automatically. You don’t install anything varlock-specific; varlock already speaks the completion protocol that package-manager completion uses.
Set up completion for your package manager once, using @bomb.sh/tab:
npm install -g @bomb.sh/tab
# zsh (swap in npm / yarn / bun and bash / fish / powershell as needed)echo 'source <(tab pnpm zsh)' >> ~/.zshrcsource ~/.zshrcNow pnpm exec varlock <TAB>, pnpm dlx varlock <TAB>, and bare pnpm varlock <TAB> complete varlock’s subcommands and flags. The same works for npm exec, yarn, and bun x.
What gets completed
Section titled “What gets completed”Tab completion covers varlock subcommands and static flags (including enum choices like load --format).
Dynamic values, such as env var names from your schema, are not completed yet.
Troubleshooting
Section titled “Troubleshooting”If completions stop working after an upgrade, regenerate the script:
npm exec -- varlock complete zsh > ~/.zsh/completions/_varlockpnpm exec -- varlock complete zsh > ~/.zsh/completions/_varlockbunx varlock complete zsh > ~/.zsh/completions/_varlockvlx -- varlock complete zsh > ~/.zsh/completions/_varlockyarn exec -- varlock complete zsh > ~/.zsh/completions/_varlockvarlock complete zsh > ~/.zsh/completions/_varlockReplace zsh and the output path with your shell and install location.