How to complete rustup/cargo commands?

Viewed 193

I have rustup+rust+cargo installed using the official installation script.

How do I enable shell completions, to be able to type cargo <TAB> in the terminal and see the possible commands such as cargo check?

1 Answers

You can run rustup completions and follow the instructions. For example, for bash you can run

rustup completions bash       > ~/.local/share/bash-completion/completions/rustup
rustup completions bash cargo > ~/.local/share/bash-completion/completions/cargo

to generate completions for rustup and cargo respectively. Consult rustup completions for further details, e.g. for configuring zsh and fish completions.

Related