rsigma completions

rsigma completions

Added in v0.29.0

Print a tab-completion script for your shell. It completes every command group, subcommand, and flag, and the values of flags with a fixed set of choices (for example --output-format).

Synopsis

rsigma completions [SHELL]

Description

The script is generated from the binary’s own command definitions, so it always matches the installed version, including the commands that optional Cargo features add. Regenerate it after upgrading rsigma.

Without SHELL, rsigma takes the shell from the file name in the SHELL environment variable (/bin/zsh selects zsh). On Windows, when SHELL is unset, it selects powershell. When the shell cannot be detected, the command exits with code 3 and lists the supported shells.

The script goes to stdout. Redirect it to the file your shell loads completions from, as shown below.

Arguments

Argument Default Description
SHELL detected from SHELL One of bash, elvish, fish, powershell, zsh.

Installing the script

Bash (with the bash-completion package, which loads scripts from this directory on demand):

mkdir -p ~/.local/share/bash-completion/completions
rsigma completions bash > ~/.local/share/bash-completion/completions/rsigma

Bash without bash-completion: add this line to ~/.bashrc instead:

source <(rsigma completions bash)

Zsh: write the script to a directory on fpath, then make sure ~/.zshrc adds that directory before it runs compinit:

mkdir -p ~/.zfunc
rsigma completions zsh > ~/.zfunc/_rsigma
# ~/.zshrc
fpath=(~/.zfunc $fpath)
autoload -Uz compinit && compinit

Fish:

rsigma completions fish > ~/.config/fish/completions/rsigma.fish

PowerShell: add this line to your profile ($PROFILE):

rsigma completions powershell | Out-String | Invoke-Expression

Elvish: add this line to ~/.config/elvish/rc.elv:

eval (rsigma completions elvish | slurp)

Open a new shell for the change to take effect.

Examples

$ SHELL=/bin/zsh rsigma completions | head -1
#compdef rsigma
$ rsigma rule va<TAB>
$ rsigma rule validate

Exit codes

Code Meaning
0 The script was printed.
2 SHELL names an unsupported shell.
3 No shell was given and none could be detected from the SHELL environment variable.

See also