devbestiacargocompletion - experimental autocompletion for cargo and cargo-auto in bash
repository; version: 2021.817.1148 date: 2021-08-17 authors: Luciano Bestia
Install the binary:
bash
cargo install dev_bestia_cargo_completion
Save definition for auto_completion in bash:
bash
complete -C "dev_bestia_cargo_completion" cargo
Start typing cargo b
and press tab
.
It should auto-complete to cargo build
.
Congratulation! You just used auto-completion :-)
Auto-completion in Debian bash is a great tool. You type the first letters, press tab and the word is auto-completed.
Bash can call an executable binary to return the available words. So it can be written in Rust. This can produce even better results as known as dynamic auto-completion
.
For my knowledge cargo
does not have auto-completion yet. There are many plans. It can take some time.
I will build what I need now. Something simple. It doesn't need to be perfect.
This is a great blog:
https://www.joshmcguigan.com/blog/shell-completions-pure-rust/
The Linux command complete
adds auto_completion definitions to bash.
```bash
complete
complete -r cargo
complete -C "binary" command ```
I choose this long name for my crate, because cargo-completion is a hot topic. Sooner or later someone will build it - officially. This is why I added the prefix dev_bestia_
, because my web domain is bestia.dev. This way I have the guarantee of a unique name and leave the short name to the future official version.
Run
bash
cargo install cargo-auto
and then list the user-defined automation tasks with
bash
cargo auto
You can save the definition for bash auto-completion for this project in development. So you can test the auto-completion while developing it.
bash
complete -C "/home/luciano/rustprojects/dev_bestia_cargo_completion/target/debug/dev_bestia_cargo_completion" cargo
We leave in times of danger with supply chain attacks
.
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
You can also read reviews quickly on the web. Example for the crate num-traits
:
https://web.crev.dev/rust-reviews/crate/num-traits/
My open-source projects are free and free as a beer (MIT license).
I just love programming.
But I need also to drink. If you find my projects and tutorials helpful, please buy me a beer or two donating on my paypal. You know the price of a beer in your local bar ;-)
So I can drink a free beer for your health :-)
Na zdravje !