@@ -11,6 +11,16 @@ ALIAS="pg"
1111# saved locally under $CMD, so the old `dot` command name is gone.
1212ASSET_PREFIX=" dot"
1313
14+ # Record whether the command ALREADY resolves on the caller's PATH (re-install /
15+ # upgrade) before we touch anything. We install into BOTH $INSTALL_DIR/bin and
16+ # ~/.local/bin (the symlinks below); ~/.local/bin is already on PATH by default
17+ # on Debian/Ubuntu, so a "fresh" install there resolves immediately. Check both
18+ # dirs so the reload hint is suppressed whenever the command already works.
19+ case " :$PATH :" in
20+ * " :$INSTALL_DIR /bin:" * |* " :$HOME /.local/bin:" * ) ALREADY_ON_PATH=1 ;;
21+ * ) ALREADY_ON_PATH=0 ;;
22+ esac
23+
1424# 1) Detect platform. Git Bash / MSYS / Cygwin report MINGW*/MSYS*/CYGWIN* —
1525# point Windows users at WSL instead of a bare "Unsupported OS".
1626OS=$( 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 +148,16 @@ echo -e "${Y}│${R} ${Y}│${R}"
138148echo -e " ${Y} │${R} ${B} $CMD login${R} ${Y} │${R} "
139149echo -e " ${Y} ╰────────────────────────────────────────╯${R} "
140150echo -e " ${D} Tip: ${ALIAS} is a short alias for ${CMD} .${R} "
151+
152+ # This script runs in a child process, so it CANNOT add $CMD to the caller's
153+ # live PATH — sourcing an rc file here would only touch this dying process, not
154+ # the parent shell. On a fresh install the command therefore won't resolve until
155+ # the caller's shell reloads, so print the exact reload command for their shell.
156+ if [ " $ALREADY_ON_PATH " = " 0" ]; then
157+ case " $( basename " ${SHELL:- bash} " ) " in
158+ zsh) RC=" $HOME /.zshrc" ;;
159+ fish) RC=" $HOME /.config/fish/config.fish" ;;
160+ * ) RC=" $HOME /.bashrc" ;;
161+ esac
162+ echo -e " ${D} First run \033[1msource ${RC/# $HOME / \$ HOME}${R}${D} (or open a new terminal) to use ${CMD} .${R} "
163+ fi
0 commit comments