Skip to content

Commit abdec51

Browse files
shawntabriziclaude
andcommitted
fix: print shell reload hint after fresh install (#317)
A curl|bash install runs in a child process and cannot mutate the caller's live PATH, so the new playground/pg command isn't found until the shell reloads. Detect a fresh install and print the exact source command for the user's shell (zsh/bash/fish) so they can use it now. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a5e09ab commit abdec51

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"playground-cli": patch
3+
---
4+
5+
install.sh now prints a shell-specific reload hint (`source ~/.zshrc` / `~/.bashrc` / fish config, or open a new terminal) on a fresh install, so users aren't left with a `playground`/`pg` command that isn't found until they manually reload their shell.

install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ ALIAS="pg"
1111
# saved locally under $CMD, so the old `dot` command name is gone.
1212
ASSET_PREFIX="dot"
1313

14+
# Record whether our bin dir is ALREADY on the caller's PATH (re-install /
15+
# upgrade) before we touch anything. On a fresh install it isn't, so the new
16+
# command won't resolve in the caller's shell until that shell reloads its
17+
# config — we print an exact reload hint at the end for that case only.
18+
case ":$PATH:" in *":$INSTALL_DIR/bin:"*) ALREADY_ON_PATH=1 ;; *) ALREADY_ON_PATH=0 ;; esac
19+
1420
# 1) Detect platform. Git Bash / MSYS / Cygwin report MINGW*/MSYS*/CYGWIN* —
1521
# point Windows users at WSL instead of a bare "Unsupported OS".
1622
OS=$(uname -s); case "$OS" in Linux) OS=linux;; Darwin) OS=darwin;; MINGW*|MSYS*|CYGWIN*) echo "Windows is not supported natively. Install WSL (https://learn.microsoft.com/windows/wsl/install) and re-run this command inside it."; exit 1;; *) echo "Unsupported OS: $OS"; exit 1;; esac
@@ -138,3 +144,16 @@ echo -e "${Y}│${R} ${Y}│${R}"
138144
echo -e "${Y}${R} ${B}$CMD login${R} ${Y}${R}"
139145
echo -e "${Y}╰────────────────────────────────────────╯${R}"
140146
echo -e "${D} Tip: ${ALIAS} is a short alias for ${CMD}.${R}"
147+
148+
# This script runs in a child process, so it CANNOT add $CMD to the caller's
149+
# live PATH — sourcing an rc file here would only touch this dying process, not
150+
# the parent shell. On a fresh install the command therefore won't resolve until
151+
# the caller's shell reloads, so print the exact reload command for their shell.
152+
if [ "$ALREADY_ON_PATH" = "0" ]; then
153+
case "$(basename "${SHELL:-bash}")" in
154+
zsh) RC="$HOME/.zshrc" ;;
155+
fish) RC="$HOME/.config/fish/config.fish" ;;
156+
*) RC="$HOME/.bashrc" ;;
157+
esac
158+
echo -e "${D} First run \033[1msource ${RC/#$HOME/\$HOME}${R}${D} (or open a new terminal) to use ${CMD}.${R}"
159+
fi

0 commit comments

Comments
 (0)