mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 11:31:15 -03:00
Support top-level completion of user-installed cargo subcommands
This expands completions of `cargo^I` to list any commands named `cargo-xxx` as cargo subcommands invokable as `cargo xxx` in addition to the default oob subcommands cargo ships with. (This is very similar to how git allows users to shim their own subcommands.) NOTE: This would stay even after cargo someday moves to clap and generates or even ships/installs an official machine-generated `cargo.fish` completions script.
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
## --- WRITTEN MANUALLY ---
|
||||
set -l __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape)
|
||||
|
||||
# Append user-installed extensions (e.g. cargo-foo, invokable as `cargo foo`) to the list of subcommands (à la git)
|
||||
set -la __fish_cargo_subcommands (complete -C'cargo-' | string replace -rf '^cargo-(\w+).*' '$1')
|
||||
|
||||
complete -c cargo -f -c cargo -n __fish_use_subcommand -a "$__fish_cargo_subcommands"
|
||||
complete -c cargo -x -c cargo -n '__fish_seen_subcommand_from help' -a "$__fish_cargo_subcommands"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user