diff --git a/share/completions/yarn.fish b/share/completions/yarn.fish index 86d63b165..4266e9909 100644 --- a/share/completions/yarn.fish +++ b/share/completions/yarn.fish @@ -64,6 +64,16 @@ complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l tag complete -f -c yarn -n '__fish_use_subcommand' -a remove complete -f -c yarn -n '__fish_use_subcommand' -a run +function __fish_yarn_run + if test -e package.json; and type -q jq + jq -r '.scripts | to_entries | map("\(.key)\t\(.value | tostring | .[0:20])") | .[]' package.json + else if type -q jq + command yarn run --json 2> /dev/null | jq -r '.data.hints? | to_entries | map("\(.key)\t\(.value | tostring |.[0:20])") | .[]' + end +end + +complete -f -c yarn -n '__fish_seen_subcommand_from run' -a "(__fish_yarn_run)" + complete -f -c yarn -n '__fish_use_subcommand' -a tag complete -f -c yarn -n '__fish_seen_subcommand_from tag' -a 'add rm ls'