News for hackers. Stuff that matters.
Re:Fzf – the basics part 1 – layout by zjmil on Friday February 05, 2021 @02:32PM (#26040257)
You could do something like this (not super thoroughly tested):

  npmrf () {
    local script
    script=$(jq -r '.scripts | to_entries[] | "\(.key) => \(.value)"' < package.json | sort | fzf | cut -d' ' -f1) && npm run "$script"
  }

It uses jq's to_entries to pull out the script/command key pairs and then just cuts out the script name after you choose the command (assumes the command name doesn't have spaces).

There are no comments on this comment yet.