From b07af69afa7a3f729dd9f4975d70300bfbf6d517 Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 2 Nov 2026 05:44:35 -0800 Subject: [PATCH] Installer: add ~/.local/bin to PATH instead of only warning Appends an export to the profile for the user's shell (zsh: .zshrc, bash: .bash_profile on macOS / .bashrc on Linux, fish: config.fish), once, and tells the user to open a new terminal at the end of setup. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QaE1hpvyZTJixEbUUMj9Ca --- install.sh | 30 ++++++++++++++++++++++++++---- llmhost/cli.py | 2 ++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 18102b1..23c5084 100755 --- a/install.sh +++ b/install.sh @@ -86,10 +86,32 @@ PYTHONPATH="$SRC" exec "$PY" -P -m llmhost "\$@" EOF chmod +x "$BIN/llmhost" -case ":$PATH:" in - *":$BIN:"*) ;; - *) warn "$BIN isn't on your PATH. Add this to your shell profile: export PATH=\"$BIN:\$PATH\"" ;; -esac +# Put ~/.local/bin on PATH for future shells (like uv's and opencode's installers do). +add_to_path() { + case ":$PATH:" in *":$BIN:"*) return 0 ;; esac + local rc line + case "$(basename "${SHELL:-}")" in + zsh) rc="${ZDOTDIR:-$HOME}/.zshrc"; line='export PATH="$HOME/.local/bin:$PATH"' ;; + bash) if [ "$OS" = "Darwin" ]; then rc="$HOME/.bash_profile"; else rc="$HOME/.bashrc"; fi + line='export PATH="$HOME/.local/bin:$PATH"' ;; + fish) rc="$HOME/.config/fish/config.fish"; line='fish_add_path $HOME/.local/bin' ;; + *) warn "$BIN isn't on your PATH. Add it in your shell's startup file: export PATH=\"$BIN:\$PATH\""; return 0 ;; + esac + if grep -qsF '$HOME/.local/bin' "$rc" || grep -qsF "$BIN" "$rc"; then + PATH_NOTE="$rc" # already configured; only this shell is missing it + return 0 + fi + mkdir -p "$(dirname "$rc")" + printf '\n# Added by llm-host\n%s\n' "$line" >> "$rc" + say "Added $BIN to your PATH in $rc" + PATH_NOTE="$rc" +} +PATH_NOTE="" +add_to_path +if [ -n "$PATH_NOTE" ]; then + # Shown before setup's long output so it isn't missed; setup repeats it at the end. + export LLMHOST_PATH_NOTE="Open a new terminal (or run: source $PATH_NOTE) to use the llmhost command." +fi say "Running setup" exec "$BIN/llmhost" setup "$@" diff --git a/llmhost/cli.py b/llmhost/cli.py index 0fa3a30..1db7269 100644 --- a/llmhost/cli.py +++ b/llmhost/cli.py @@ -148,6 +148,8 @@ Done. if not a.no_opencode: setup_opencode(cfg, ask=sys.stdin.isatty() and not a.yes, install_ok=a.opencode) say(f"\nOther machines: run `llmhost opencode-config` here for their opencode setup.") + if os.environ.get("LLMHOST_PATH_NOTE"): + say("\n" + os.environ["LLMHOST_PATH_NOTE"]) def setup_opencode(cfg, ask, install_ok=False, later="llmhost opencode-setup"):