aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/completions/npm.fish
diff options
context:
space:
mode:
authorGravatar Stefan Maric <alexstefan92@gmail.com>2015-09-07 17:39:28 -0430
committerGravatar Fabian Homborg <FHomborg@gmail.com>2015-09-12 12:12:21 +0200
commitf898d825368bcd5ef08197a6934ec167ded550dd (patch)
treea7433f0840a6bef8476407dfe1a3635d1436a8d5 /share/completions/npm.fish
parent3b5aab6edb0aea3a02383a74479c7afacb0e76f0 (diff)
Add script values as descriptions to npm run/run-script completion
Diffstat (limited to 'share/completions/npm.fish')
-rw-r--r--share/completions/npm.fish13
1 files changed, 6 insertions, 7 deletions
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'