Yarn package.json script picker (fzf)

Optional zsh functions to fuzzy-pick yarn scripts from package.json — high ROI, no history/keybind changes

Yarn package.json script picker (fzf)

Why this exists

Commands like yarn serve:backend-api, yarn serve:gograb-space, etc. share a long prefix. History search is fine but structured picking from package.json is faster and stays correct when scripts are added or renamed.

This adds optional shell functions and aliases. It does not change Ctrl+R, arrow keys, or HISTFILE behavior.

Requirements

What was added (repo)

Path Role
tools/scripts/system/zsh-yarn-scripts-fzf.zsh Defines yarn_scripts_fzf, yarn_serve_scripts_fzf, aliases yscripts, yserve

Activation (already wired if you use the default block)

~/.zshrc should contain a guarded source (only loads if the file exists):

export GSPACE1_ROOT="${GSPACE1_ROOT:-$HOME/developer/repos-gspace/gspace1}"
_YARN_FZF_ZSH="${GSPACE1_ROOT}/tools/scripts/system/zsh-yarn-scripts-fzf.zsh"
[[ -r "$_YARN_FZF_ZSH" ]] && source "$_YARN_FZF_ZSH"
unset _YARN_FZF_ZSH

If your clone lives elsewhere, set GSPACE1_ROOT before this block or edit the default path.

Usage

From a directory that has package.json (e.g. gspace1 root):

Command Behavior
yserve Open fzf with initial query serve: — picks among serve:* script names, then runs yarn <name> (same as your usual history lines)
yscripts List all scripts from ./package.json in fzf, then yarn <name>
yarn_scripts_fzf Same as yscripts; optional args: [path/to/package.json] [fzf-query]
yarn_serve_scripts_fzf Same as yserve; optional arg: path to package.json

Examples:

cd ~/developer/repos-gspace/gspace1
yserve
# or all scripts:
yscripts
# app-level package.json:
yarn_scripts_fzf apps/some-app/package.json

Cancel fzf with Esc — nothing runs.

Safety / behavior guarantees

Revert (disable completely)

  1. Open ~/.zshrc.
  2. Find the block marked YARN_SCRIPTS_FZF_BEGIN / YARN_SCRIPTS_FZF_END (or search for zsh-yarn-scripts-fzf.zsh).
  3. Comment out or delete the whole block (from the comment header through unset _YARN_FZF_ZSH).
  4. Run exec zsh or open a new terminal.

Optional: remove aliases from an active session:

unalias yserve yscripts 2>/dev/null

See also