rustup-completions
Generate shell completions for rustup
TLDR
Print the completion script to stdout
SYNOPSIS
rustup-completions
PARAMETERS
The name of the target shell for which to generate completion scripts. Possible values include:
bash: Generates completions for the Bash shell.
zsh: Generates completions for the Zsh shell.
fish: Generates completions for the Fish shell.
powershell: Generates completions for PowerShell.
DESCRIPTION
rustup-completions is a subcommand of rustup, the Rust toolchain installer and manager. Its primary function is to generate shell completion scripts that enhance the command-line experience for users of rustup. By providing these scripts, users can benefit from tab-completion for rustup commands, subcommands, options, and arguments, significantly improving productivity and reducing typing errors.
The command typically prints the generated script to standard output (stdout), which can then be directly sourced by the user's shell or saved to a designated completions directory. It supports popular shells like Bash, Zsh, Fish, and PowerShell, making rustup more user-friendly across various environments.
CAVEATS
Users must manually configure their shell to source the output of rustup-completions for the completions to take effect. The exact method varies by shell, typically involving adding a line to the shell's configuration file (e.g., .bashrc, .zshrc, config.fish) or placing the generated script in a specific directory.
These completions are specifically for the rustup command itself and its direct subcommands, not for cargo or rustc directly (though rustup manages their installation).
INSTALLATION FOR BASH
To enable Bash completions, add the following line to your ~/.bashrc file:eval "$(rustup-completions bash)"
After saving, reload your shell (e.g., source ~/.bashrc).
INSTALLATION FOR ZSH
To enable Zsh completions, add the following to your ~/.zshrc file (adjusting paths as necessary):fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinit
rustup-completions zsh > ~/.zsh/completion/_rustup
Then reload your Zsh shell (e.g., source ~/.zshrc) or open a new terminal.
INSTALLATION FOR FISH
To enable Fish completions, run the following command:rustup-completions fish > ~/.config/fish/completions/rustup.fish
Then restart your Fish shell or open a new terminal.
HISTORY
Shell completions are a standard and highly valued feature in modern command-line interface (CLI) tools, significantly enhancing usability. As rustup evolved into the de facto tool for managing Rust toolchains, integrating robust completion support became a natural progression. rustup-completions was developed and included as part of the rustup utility to provide this essential functionality, making the rustup ecosystem more accessible and efficient for developers.