Last active
June 7, 2018 17:25
-
-
Save AndrewVos/342e37616713e8bfe1bc3cd556e64b64 to your computer and use it in GitHub Desktop.
Yarn completion for anything in "scripts". Add it to your .bashrc or whatever. Requires jq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_yarn_complete() { | |
local cur_word prev_word scripts | |
cur_word="${COMP_WORDS[COMP_CWORD]}" | |
prev_word="${COMP_WORDS[COMP_CWORD-1]}" | |
scripts=$(jq '.scripts | keys[]' package.json | paste) | |
COMPREPLY=( $(compgen -W "${scripts}" -- ${cur_word}) ) | |
return 0 | |
} | |
complete -F _yarn_complete yarn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! You could remove dependency on
jq
:scripts=$(node -e 'Object.keys(require("./package.json").scripts).forEach(s => console.log(s))')