diff options
| author | olwooz <24418404+olwooz@users.noreply.github.com> | 2025-08-17 01:29:43 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-16 18:29:43 +0200 |
| commit | 51760e1d4aa417846b41a32ad845aaacc053a7f5 (patch) | |
| tree | 5e97602ee336aece69e922b7fbf7f0dfb0f152fe /tools | |
| parent | 8bd49fb0475c8be9a9d0f5daa518a8ff3bbe78fb (diff) | |
| download | zsh-51760e1d4aa417846b41a32ad845aaacc053a7f5.tar.gz zsh-51760e1d4aa417846b41a32ad845aaacc053a7f5.tar.bz2 zsh-51760e1d4aa417846b41a32ad845aaacc053a7f5.zip | |
feat(installer): add confirmation before overwriting existing .zshrc (#13086)
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/install.sh | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/install.sh b/tools/install.sh index 5c9b2c18d..d274c2c9f 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -341,6 +341,23 @@ setup_zshrc() { echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}" return fi + + # Ask user for confirmation before backing up and overwriting + echo "${FMT_YELLOW}Found ${zdot}/.zshrc." + echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten." + echo "Make sure your .zshrc contains the following minimal configuration if you choose not to overwrite it:${FMT_RESET}" + echo "----------------------------------------" + cat "$ZSH/templates/minimal.zshrc" + echo "----------------------------------------" + printf '%sDo you want to overwrite it with the Oh My Zsh template? [Y/n]%s ' \ + "$FMT_YELLOW" "$FMT_RESET" + read -r opt + case $opt in + [Yy]*|"") ;; + [Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;; + *) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;; + esac + if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then @@ -353,7 +370,7 @@ setup_zshrc() { echo "${FMT_YELLOW}Found old .zshrc.pre-oh-my-zsh." \ "${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}" fi - echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}" + echo "${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}" mv "$zdot/.zshrc" "$OLD_ZSHRC" fi |
