mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-06 04:27:40 +00:00
shell: fish functions -> ~/.local/bin executables + bash/zsh ports; manage ~/.agents
- 16 cross-shell utilities converted to sh/bash chezmoi executables: ai c2p cp-appid extract_agents fab gdc gh-sonr-org-migrate ghg-clone ghn gho git-summary launch_omp_livediff_overlay lc-elir mdcp mdp pj (ghg-clone not named ghg: unrelated cargo binary owns that name) - cwd/history helpers stay per-shell: yy c cd clip-last + ghg/ghn/gho cd-wrappers in bash/functions/ and zsh/functions/, loaded by rc files - fish keeps only shell-state functions; converted ones now hit PATH - cp-appid ignore gating moved to .local/bin path - dot_agents/skills: 82 skills materialized from dotstate storage so dot_claude skill symlinks resolve on fresh bootstrap; dotstate profile/symlinks.json released .agents/skills .bashrc .zshrc
This commit is contained in:
1 parent
6776366ce6
commit
6406208b35
637 files changed
+100297
-497
No files matched your search
@@ -1,86 +0,0 @@
|
||||
function pj --description "fzf package.json script runner with auto-detected package manager"
|
||||
# ── Locate nearest package.json (walk up) ──────────────────────────
|
||||
set -l dir (pwd)
|
||||
set -l pkg ""
|
||||
while true
|
||||
if test -f "$dir/package.json"
|
||||
set pkg "$dir/package.json"
|
||||
break
|
||||
end
|
||||
test "$dir" = / && break
|
||||
set dir (path dirname $dir)
|
||||
end
|
||||
|
||||
if test -z "$pkg"
|
||||
echo "pj: no package.json found in this tree" >&2
|
||||
return 1
|
||||
end
|
||||
set -l root (path dirname $pkg)
|
||||
|
||||
# ── Detect package manager ─────────────────────────────────────────
|
||||
# Priority: packageManager field (corepack) → lockfiles (walking up
|
||||
# past $root to catch monorepo-root locks) → npm fallback
|
||||
set -l pm (jq -r '.packageManager // empty' $pkg | string split '@')[1]
|
||||
|
||||
if test -z "$pm"
|
||||
set -l d $root
|
||||
while test -z "$pm"
|
||||
if test -f "$d/bun.lockb" -o -f "$d/bun.lock"
|
||||
set pm bun
|
||||
else if test -f "$d/pnpm-lock.yaml"
|
||||
set pm pnpm
|
||||
else if test -f "$d/yarn.lock"
|
||||
set pm yarn
|
||||
else if test -f "$d/package-lock.json"
|
||||
set pm npm
|
||||
end
|
||||
test "$d" = / && break
|
||||
set d (path dirname $d)
|
||||
end
|
||||
test -z "$pm" && set pm npm
|
||||
end
|
||||
|
||||
# ── Pick a script ──────────────────────────────────────────────────
|
||||
set -l script (jq -r '.scripts // {} | keys[]' $pkg | fzf \
|
||||
--prompt="$pm run ❯ " \
|
||||
--header="$root" \
|
||||
--height=40% --layout=reverse --border \
|
||||
--preview="jq -r --arg s {} '.scripts[\$s]' $pkg" \
|
||||
--preview-window=up:2:wrap)
|
||||
|
||||
test -z "$script" && return 0
|
||||
|
||||
# ── Run (npm needs `--` to forward extra args) ────────────────────
|
||||
set -l extra $argv
|
||||
if test "$pm" = npm -a (count $extra) -gt 0
|
||||
set extra -- $extra
|
||||
end
|
||||
|
||||
# Wrap long-running server scripts in openlogs (live log tail for agents).
|
||||
# Matches dev/start/serve and namespaced variants like dev:web, start:api.
|
||||
set -l wrapper
|
||||
if string match -qr '^(dev|start|serve|watch)(:.*)?$' -- $script
|
||||
# Resolve the binary: PATH → mise resolution → mise installs glob
|
||||
set -l ol (command -s openlogs)
|
||||
if test -z "$ol"; and command -sq mise
|
||||
set ol (mise which openlogs 2>/dev/null)
|
||||
end
|
||||
if test -z "$ol"
|
||||
set ol ~/.local/share/mise/installs/node/*/bin/openlogs
|
||||
set ol $ol[1]
|
||||
end
|
||||
|
||||
if test -n "$ol" -a -x "$ol"
|
||||
set wrapper $ol
|
||||
else
|
||||
echo "pj: openlogs not found, running unwrapped" >&2
|
||||
end
|
||||
end
|
||||
if test -n "$wrapper"
|
||||
echo "→ $wrapper $pm run $script $argv" >&2
|
||||
$wrapper $pm run $script $extra
|
||||
else
|
||||
echo "→ $pm run $script $argv" >&2
|
||||
$pm run $script $extra
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user