Skip to content
← Today I learned

Quickly Inspect package.json Scripts

A one-line shell function that prints the scripts block of any package.json, so you stop opening the file to remember a command name.

  • 1 min read

Not exactly new knowledge, but today I felt like adding another utility alias to my toolkit:

package-scripts() {
  cat package.json | jq ".scripts"
}

This tiny shell function spits out all the scripts defined in your package.json file. It’s a swift way to review available scripts without the hassle of scrolling through endless dependencies in the file.

For those dabbling with nushell, the equivalent command would be a breeze: open package.json | get scripts. Still getting my feet wet with nushell, so for now, this zsh alias will do the job.

  • bash
  • shell
  • json

Comments