How to add rustup and cargo auto-completions?

After installing Rust using this command:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

I was trying to find a way to add the auto-completions for rustup and cargo.
Now that i have done it, i am sharing the way i did it for future reference and for anyone facing the same issue. If you have a better solution please share it here.

  1. Generate the auto-completions for cargo and rustup and save them to Downloads/:
    rustup completions zsh > ~/Downloads/_rustup && rustup completions zsh cargo > ~/Downloads/_cargo

  2. Move the files generated to /usr/share/zsh/functions/Completion/Zsh/:
    sudo mv ~/Downloads/_cargo ~/Downloads/_rustup /usr/share/zsh/functions/Completion/Zsh/

  3. Refresh zsh: exec zsh

Used the repo packages. They include bash and zsh auto-completions files.

If you don’t like the regular rust package, because you fear Manjaro stable lacks behind current versions, use the rustup package. With it, you can install your own tool-chain. Both packages include the auto-completion files.

2 Likes

Thanks, this helped a lot. It’s less pain.
Uninstalled rust rustup self uninstall and used the package provided by the repo. They are up to date.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.