Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Yarn completion for anything in "scripts". Add it to your .bashrc or whatever. Requires jq
_yarn_complete() {
local cur_word prev_word scripts
scripts=$(jq '.scripts | keys[]' package.json | paste)
COMPREPLY=( $(compgen -W "${scripts}" -- ${cur_word}) )
return 0
complete -F _yarn_complete yarn

This comment has been minimized.

Copy link

@artemave artemave commented Jun 7, 2018

Nice! You could remove dependency on jq:

scripts=$(node -e 'Object.keys(require("./package.json").scripts).forEach(s => console.log(s))')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment