lpm completions
Generate and load shell completions for Bash, Zsh, Fish, PowerShell, or Elvish.
Generate a completion script for command names, flags, and supported argument values.
lpm completions <SHELL>Quickstart
For the current Bash session:
source <(lpm completions bash)Type lpm , then press Tab. Use the recipes below to save completions for later sessions.
| Shell | <SHELL> | Load method |
|---|---|---|
| Bash | bash | Source the generated script. |
| Zsh | zsh | Save _lpm in a directory on fpath, then initialize completions. |
| Fish | fish | Save the script in the Fish completions directory. |
| PowerShell | powershell | Evaluate the script, or load a separate .ps1 file. |
| Elvish | elvish | Evaluate the script from rc.elv. |
This command needs no project, registry connection, or lpm.json configuration. It writes the script to standard output without an interactive prompt.
Shell recipes
Bash
Save and load the script:
mkdir -p ~/.local/share/bash-completion/completions
lpm completions bash > ~/.local/share/bash-completion/completions/lpm
source ~/.local/share/bash-completion/completions/lpmTo load it in later interactive sessions, add this line to ~/.bashrc:
source ~/.local/share/bash-completion/completions/lpmIf your terminal starts a login shell, make sure that its Bash profile loads ~/.bashrc.
Zsh
Save the script:
mkdir -p ~/.zfunc
lpm completions zsh > ~/.zfunc/_lpmAdd the directory before your existing compinit call in ~/.zshrc:
fpath=(~/.zfunc $fpath)
autoload -Uz compinit
compinitIf your shell framework already calls compinit, add only the fpath line before the framework loads. Then start a new shell.
Fish
mkdir -p ~/.config/fish/completions
lpm completions fish > ~/.config/fish/completions/lpm.fish
source ~/.config/fish/completions/lpm.fishIf you set XDG_CONFIG_HOME, replace ~/.config with that directory. Fish loads saved completions in later sessions.
PowerShell
For the current session:
lpm completions powershell | Out-String | Invoke-ExpressionTo save the script beside your profile:
$profileDir = Split-Path -Parent $PROFILE
New-Item -ItemType Directory -Force $profileDir | Out-Null
lpm completions powershell | Set-Content -Encoding utf8 (Join-Path $profileDir 'lpm-completions.ps1')Add this line to $PROFILE:
. (Join-Path (Split-Path -Parent $PROFILE) 'lpm-completions.ps1')The generated script contains using namespace declarations. Keep it in a separate file so those declarations precede other statements.
Elvish
Add this line to ~/.config/elvish/rc.elv:
eval (lpm completions elvish | slurp)This recipe generates completions when the shell starts. Run the same line to load them in the current session.
Refresh and troubleshoot
Saved scripts describe the LPM CLI version that generated them. After an update, repeat the generation command and reload the script or restart your shell.
Dynamic recipes regenerate completions each time they run. They require lpm on PATH during shell startup.
If Tab does not show LPM CLI candidates, make sure that the script loaded in the current shell. For Zsh, also verify the fpath order.
The scripts include public commands and flags. They omit hidden internal commands and options.
Bash and Zsh also complete enumerated argument values. Fish completes enumerated option values. PowerShell and Elvish primarily complete commands and flags.
Completion scripts do not query registries for package names or read project scripts for suggestions.
Output and flags
lpm completions bash > lpm-completions.bash| Argument or flag | Effect |
|---|---|
<SHELL> | Required. bash, zsh, fish, powershell, or elvish. |
--json | Keep the raw completion script. No JSON envelope. |
--verbose | Leave the generated script unchanged. |
Successful generation exits 0. An invalid shell exits 2. Other output failures return a nonzero status. A closed output pipe exits quietly.
See global flags for shared options.
See also
- Installation — install LPM CLI and configure
PATH. lpm self-update— update LPM CLI before regenerating saved scripts.- Commands — browse the command reference.