Generate shell completion scripts for bash, zsh, fish, or powershell. Once installed, pressing Tab completes commands, subcommands, flags, and many argument values automatically.
# zsh (recommended on macOS)
nself completion zsh > ~/.zsh/_nself
echo 'fpath=(~/.zsh $fpath)' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
exec zsh
# bash (Linux)
nself completion bash > /etc/bash_completion.d/nself
# fish
nself completion fish > ~/.config/fish/completions/nself.fish
# PowerShell
nself completion powershell | Out-String | Invoke-Expressionnself completion <SHELL>| Argument | Description |
|---|---|
bash | Generate Bash completion script |
zsh | Generate Zsh completion script |
fish | Generate Fish completion script |
powershell | Generate PowerShell completion script |
Zsh completion uses a function file convention. The _nself filename tells Zsh this is a completion function for the nself command.
# Create the completions directory if it doesn't exist
mkdir -p ~/.zsh
# Generate the completion file
nself completion zsh > ~/.zsh/_nself
# Add to your ~/.zshrc if not already present:
echo 'fpath=(~/.zsh $fpath)' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
# Reload your shell
exec zsh
# Verify — pressing Tab after "nself " should show subcommands
nself <Tab>On most Linux distributions, scripts placed in /etc/bash_completion.d/ are sourced automatically by the bash-completion package.
# System-wide (requires sudo)
nself completion bash | sudo tee /etc/bash_completion.d/nself
# Per-user (no sudo needed)
mkdir -p ~/.local/share/bash-completion/completions
nself completion bash > ~/.local/share/bash-completion/completions/nself
# Reload
source ~/.bashrcFish completion scripts live in ~/.config/fish/completions/. Fish sources them automatically at startup.
# Install
nself completion fish > ~/.config/fish/completions/nself.fish
# No reload needed — fish picks it up on next invocationPowerShell completion can be loaded for the current session or added permanently via your PowerShell profile.
# Current session only
nself completion powershell | Out-String | Invoke-Expression
# Permanent — add to your $PROFILE
nself completion powershell >> $PROFILE
# Verify profile path
echo $PROFILEThe generated completion scripts handle:
up, down)nself db migrate <Tab> shows up down status create verify-checksums reset-checksum)nself db migrate --env <Tab> shows dev staging prod)nself logs <Tab>)After upgrading the nself CLI to a new version, regenerate the completion script to pick up any new commands or flags:
# Re-generate for zsh
nself completion zsh > ~/.zsh/_nself
exec zsh # reload# For zsh: check that compinit is called in your .zshrc
grep compinit ~/.zshrc
# For zsh: force rebuild of completion cache
rm -f ~/.zcompdump
exec zsh
# For bash: verify the completion is loaded
complete -p nselfThis usually means the completion file is not on the fpath (zsh) or is not being sourced (bash). Double-check the installation steps above match your shell version.