Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active July 29, 2020 13:27
Show Gist options
  • Save kopiro/83419bdd24ec1107e81f5095c3035bc2 to your computer and use it in GitHub Desktop.
Save kopiro/83419bdd24ec1107e81f5095c3035bc2 to your computer and use it in GitHub Desktop.
Yarn run fuzzy matching
pkgj-run-list() {
jq .scripts package.json | grep -o '.*\":' | sed -nE 's/\"(.*)\":/\1/p' | awk '{$1=$1};1' | fzf | tr -d '\r' | tr -d '\n'
}
yarn-x() {
PKG_CMD=$(pkgj-run-list)
[ -n "$PKG_CMD" ] && print -s "yarn $PKG_CMD" && yarn "$PKG_CMD"
}
alias yx="yarn-x"
npm-x() {
PKG_CMD=$(pkgj-run-list)
[ -n "$PKG_CMD" ] && print -s "npm run $PKG_CMD" && npm run "$PKG_CMD"
}
@kopiro
Copy link
Author

kopiro commented Jul 29, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment