From f898d825368bcd5ef08197a6934ec167ded550dd Mon Sep 17 00:00:00 2001 From: Stefan Maric Date: Mon, 7 Sep 2015 17:39:28 -0430 Subject: Add script values as descriptions to npm run/run-script completion --- share/completions/npm.fish | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'share/completions/npm.fish') diff --git a/share/completions/npm.fish b/share/completions/npm.fish index ac0e264f..595143a8 100644 --- a/share/completions/npm.fish +++ b/share/completions/npm.fish @@ -31,11 +31,6 @@ function __fish_npm_settings command npm config ls -l | command grep -o '.* =' | command tr -d '; ' | command tr -d ' =' end -# return everything that can be used with the npm run command -function __fish_npm_run - command npm run | command grep '^ [^ ]' | command tr -d ' ' -end - # cache complete -f -c npm -n '__fish_npm_needs_command' -a 'cache' -d "Manipulates package's cache" complete -f -c npm -n '__fish_npm_using_command cache' -a 'add' -d 'Add the specified package to the local cache' @@ -112,8 +107,12 @@ for c in 'up' 'update' end # run -complete -f -c npm -n "__fish_npm_using_command run" -a '(__fish_npm_run)' -complete -f -c npm -n "__fish_npm_using_command run-script" -a '(__fish_npm_run)' +command npm run | command tail -n +2 | command sed "s/^ *//" | while read -l name + set -l trim 20 + read -l value + complete -f -c npm -n "__fish_npm_using_command run" -a (printf "%s " "$name") -d (echo "$value" | cut -c1-$trim) + complete -f -c npm -n "__fish_npm_using_command run-script" -a (printf "%s " "$name") -d (echo "$value" | cut -c1-$trim) +end # misc shorter explanations complete -f -c npm -n '__fish_npm_needs_command' -a 'adduser add-user login' -d 'Add a registry user account' -- cgit v1.2.3