Created
September 15, 2023 21:49
-
-
Save nucliweb/b421517aa73f02339b960e3d5f875298 to your computer and use it in GitHub Desktop.
List and select npm scripts
This file contains 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
## Requisites | |
## fzf https://github.com/junegunn/fzf | |
## jq https://jqlang.github.io/jq/ | |
_nr () { | |
local cmd | |
local TASK=$(npm run | egrep '^\s' | awk '{gsub(/ /,""); print}' | awk 'NR%2==1' | fzf --preview 'jq .scripts package.json' | awk '{gsub(/ /,""); print}') | |
if [ -n "$TASK" ]; then | |
cmd="npm run \"$TASK\"" | |
eval "$cmd" & | |
fi | |
} | |
zle -N _nr | |
bindkey '^o' _nr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment