Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/install-path-reload-hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"playground-cli": patch
---

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.
23 changes: 23 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ ALIAS="pg"
# saved locally under $CMD, so the old `dot` command name is gone.
ASSET_PREFIX="dot"

# Record whether the command ALREADY resolves on the caller's PATH (re-install /
# upgrade) before we touch anything. We install into BOTH $INSTALL_DIR/bin and
# ~/.local/bin (the symlinks below); ~/.local/bin is already on PATH by default
# on Debian/Ubuntu, so a "fresh" install there resolves immediately. Check both
# dirs so the reload hint is suppressed whenever the command already works.
case ":$PATH:" in
*":$INSTALL_DIR/bin:"*|*":$HOME/.local/bin:"*) ALREADY_ON_PATH=1 ;;
*) ALREADY_ON_PATH=0 ;;
esac

# 1) Detect platform. Git Bash / MSYS / Cygwin report MINGW*/MSYS*/CYGWIN* —
# point Windows users at WSL instead of a bare "Unsupported OS".
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
Expand Down Expand Up @@ -138,3 +148,16 @@ echo -e "${Y}│${R} ${Y}│${R}"
echo -e "${Y}│${R} ${B}$CMD login${R} ${Y}│${R}"
echo -e "${Y}╰────────────────────────────────────────╯${R}"
echo -e "${D} Tip: ${ALIAS} is a short alias for ${CMD}.${R}"

# This script runs in a child process, so it CANNOT add $CMD to the caller's
# live PATH — sourcing an rc file here would only touch this dying process, not
# the parent shell. On a fresh install the command therefore won't resolve until
# the caller's shell reloads, so print the exact reload command for their shell.
if [ "$ALREADY_ON_PATH" = "0" ]; then
case "$(basename "${SHELL:-bash}")" in
zsh) RC="$HOME/.zshrc" ;;
fish) RC="$HOME/.config/fish/config.fish" ;;
*) RC="$HOME/.bashrc" ;;
esac
echo -e "${D} First run \033[1msource ${RC/#$HOME/\$HOME}${R}${D} (or open a new terminal) to use ${CMD}.${R}"
fi
Loading