From 939fd58a49f5176646fbd54396c580063368d3cd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 16 Mar 2026 11:01:42 -0400 Subject: [PATCH] Skip shell config modification in non-interactive mode Prevents install.sh from silently writing to dotfiles (.zshrc, .bashrc, config.fish) when run non-interactively (e.g. by an AI coding agent). In non-interactive mode, it now prints the manual PATH export instead. Co-Authored-By: Claude Opus 4.6 (1M context) --- install.sh | 72 +++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/install.sh b/install.sh index e3a232e6b..9315e0ca7 100755 --- a/install.sh +++ b/install.sh @@ -102,42 +102,48 @@ else tilde_bin_dir=$(tildify "$INSTALL_DIR") echo "" >&2 - case $(basename "${SHELL:-sh}") in - zsh) - : "${ZDOTDIR:="$HOME"}" - shell_config="${ZDOTDIR%/}/.zshrc" - { - printf '\n# fabro\n' - echo "export PATH=\"$INSTALL_DIR:\$PATH\"" - } >>"$shell_config" - info "Added ${BOLD_CYAN}${tilde_bin_dir}${RESET} to \$PATH in ${BOLD_CYAN}$(tildify "$shell_config")${RESET}" - ;; - bash) - shell_config="$HOME/.bashrc" - if [ -f "$HOME/.bash_profile" ]; then - shell_config="$HOME/.bash_profile" - fi - { - printf '\n# fabro\n' - echo "export PATH=\"$INSTALL_DIR:\$PATH\"" - } >>"$shell_config" - info "Added ${BOLD_CYAN}${tilde_bin_dir}${RESET} to \$PATH in ${BOLD_CYAN}$(tildify "$shell_config")${RESET}" - ;; - fish) - fish_config="$HOME/.config/fish/config.fish" - mkdir -p "$(dirname "$fish_config")" - { - printf '\n# fabro\n' - echo "fish_add_path $INSTALL_DIR" - } >>"$fish_config" - info "Added ${BOLD_CYAN}${tilde_bin_dir}${RESET} to \$PATH in ${BOLD_CYAN}$(tildify "$fish_config")${RESET}" - ;; - *) + if [ -t 2 ] && [ -e /dev/tty ]; then + case $(basename "${SHELL:-sh}") in + zsh) + : "${ZDOTDIR:="$HOME"}" + shell_config="${ZDOTDIR%/}/.zshrc" + { + printf '\n# fabro\n' + echo "export PATH=\"$INSTALL_DIR:\$PATH\"" + } >>"$shell_config" + info "Added ${BOLD_CYAN}${tilde_bin_dir}${RESET} to \$PATH in ${BOLD_CYAN}$(tildify "$shell_config")${RESET}" + ;; + bash) + shell_config="$HOME/.bashrc" + if [ -f "$HOME/.bash_profile" ]; then + shell_config="$HOME/.bash_profile" + fi + { + printf '\n# fabro\n' + echo "export PATH=\"$INSTALL_DIR:\$PATH\"" + } >>"$shell_config" + info "Added ${BOLD_CYAN}${tilde_bin_dir}${RESET} to \$PATH in ${BOLD_CYAN}$(tildify "$shell_config")${RESET}" + ;; + fish) + fish_config="$HOME/.config/fish/config.fish" + mkdir -p "$(dirname "$fish_config")" + { + printf '\n# fabro\n' + echo "fish_add_path $INSTALL_DIR" + } >>"$fish_config" + info "Added ${BOLD_CYAN}${tilde_bin_dir}${RESET} to \$PATH in ${BOLD_CYAN}$(tildify "$fish_config")${RESET}" + ;; + *) + info "Add ${BOLD_CYAN}${tilde_bin_dir}${RESET} to your PATH:" + echo "" >&2 + info " ${BOLD}export PATH=\"${INSTALL_DIR}:\$PATH\"${RESET}" + ;; + esac + else info "Add ${BOLD_CYAN}${tilde_bin_dir}${RESET} to your PATH:" echo "" >&2 info " ${BOLD}export PATH=\"${INSTALL_DIR}:\$PATH\"${RESET}" - ;; - esac + fi export PATH="${INSTALL_DIR}:$PATH" fi