cmd completion - nself-org/cli GitHub Wiki

nself completion

Generate shell completion scripts.

Synopsis

nself completion [bash|zsh|fish|powershell]

Description

nself completion generates shell completion scripts for Bash, Zsh, Fish, and PowerShell. Once installed, pressing Tab completes nself commands, subcommands, and flags in your shell.

Completion scripts are generated by Cobra and cover all commands and flags defined in the CLI. Run nself completion <shell> to print the script, then follow the installation steps for your shell below.

Subcommands

Subcommand Description
bash Generate Bash completion script
zsh Generate Zsh completion script
fish Generate Fish completion script
powershell Generate PowerShell completion script

Installation

Bash

# Add to current session only
eval "$(nself completion bash)"

# Persist across sessions (append to file)
nself completion bash >> ~/.bash_completion
source ~/.bash_completion

# System-wide on Linux
nself completion bash > /etc/bash_completion.d/nself

# System-wide on macOS with Homebrew bash
nself completion bash > "$(brew --prefix)/etc/bash_completion.d/nself"

Zsh

# Add to current session only
eval "$(nself completion zsh)"

# Persist across sessions via ~/.zshrc
echo 'eval "$(nself completion zsh)"' >> ~/.zshrc

# Or write to a fpath directory and use autoload
nself completion zsh > ~/.zsh/_nself
# Add these lines to ~/.zshrc if not already present:
#   fpath=(~/.zsh $fpath)
#   autoload -Uz compinit
#   compinit

Fish

# Add to current session only
nself completion fish | source

# Persist across sessions
nself completion fish > ~/.config/fish/completions/nself.fish

PowerShell

# Add to current session only
nself completion powershell | Out-String | Invoke-Expression

# Persist for the current user across sessions
nself completion powershell > $PROFILE.CurrentUserAllHosts

# Or append to the existing profile
nself completion powershell | Out-String | Add-Content $PROFILE.CurrentUserAllHosts

Examples

# Generate and print the Bash completion script
nself completion bash
# Install Bash completions for the current session
eval "$(nself completion bash)"
# Install Zsh completions for the current session
eval "$(nself completion zsh)"
# Install Fish completions persistently
nself completion fish > ~/.config/fish/completions/nself.fish
# Install PowerShell completions for the current user
nself completion powershell > $PROFILE.CurrentUserAllHosts

See Also

Commands | Home

⚠️ **GitHub.com Fallback** ⚠️