mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-08 03:10:26 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
2cf15d0a8d
commit
939fd58a49
1 changed files with 39 additions and 33 deletions
72
install.sh
72
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue