From 7dbc36fd5ed728a61a266148665f8a59c03f1ea0 Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 7 Oct 2025 13:37:20 +0300 Subject: [PATCH 1/2] Improve uninstall script to preserve current config before restoration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The uninstall script was blindly restoring from an old backup file created during initial installation, potentially overwriting months or years of user changes made after installing bash-it. **Problem:** Users who ran uninstall.sh would lose all changes made to their bashrc since the initial bash-it installation, with no way to recover them. **Solution:** Before restoring the old backup, create a new backup of the current config at ~/.bashrc.pre-uninstall.bak (or ~/.bash_profile.pre-uninstall.bak). **Benefits:** - Users' current configurations are preserved - Users can review and merge changes if needed - Clear messaging about where to find the backup - Backwards compatible with existing behavior **Testing:** - Passes shellcheck with no warnings - Passes shfmt formatting checks Closes #2238 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- uninstall.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index c59bf932a7..929f9460f2 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -49,10 +49,18 @@ if [[ ! -e "${HOME?}/$BACKUP_FILE" ]]; then && mv "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.uninstall" \ && printf '\e[0;32m%s\e[0m\n' "Moved your ~/$CONFIG_FILE to ~/$CONFIG_FILE.uninstall." else + # Create a backup of the current config before restoring the old one + if [[ -e "${HOME?}/$CONFIG_FILE" ]]; then + cp -a "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.pre-uninstall.bak" + printf '\e[0;33m%s\e[0m\n' "Current ~/$CONFIG_FILE backed up to ~/$CONFIG_FILE.pre-uninstall.bak" + fi + test -w "${HOME?}/$BACKUP_FILE" \ && cp -a "${HOME?}/$BACKUP_FILE" "${HOME?}/$CONFIG_FILE" \ && rm "${HOME?}/$BACKUP_FILE" \ && printf '\e[0;32m%s\e[0m\n' "Your original ~/$CONFIG_FILE has been restored." + + printf '\e[0;33m%s\e[0m\n' "NOTE: If you had made changes since installing Bash-it, they are preserved in ~/$CONFIG_FILE.pre-uninstall.bak" fi printf '\n\e[0;32m%s\e[0m\n\n' "Uninstallation finished successfully! Sorry to see you go!" From 14ea9c9ca3bfa32fb6fc7776cbad45cadd705abb Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 7 Oct 2025 16:42:27 +0300 Subject: [PATCH 2/2] Fix symlink handling in uninstall backup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use -L flag with cp to dereference symlinks when backing up current config. This ensures users with homesick or other symlink-based dotfile managers get the actual file content backed up, not just another symlink. Without this fix: - User has ~/.bashrc -> ~/dotfiles/bashrc (symlink) - Uninstall creates ~/.bashrc.pre-uninstall.bak -> ~/dotfiles/bashrc (symlink) - If user later removes dotfiles repo, backup becomes dangling symlink With this fix: - User has ~/.bashrc -> ~/dotfiles/bashrc (symlink) - Uninstall creates ~/.bashrc.pre-uninstall.bak (regular file with content) - Backup is always accessible regardless of symlink target state 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- uninstall.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index 929f9460f2..d11a69b2b2 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -50,8 +50,9 @@ if [[ ! -e "${HOME?}/$BACKUP_FILE" ]]; then && printf '\e[0;32m%s\e[0m\n' "Moved your ~/$CONFIG_FILE to ~/$CONFIG_FILE.uninstall." else # Create a backup of the current config before restoring the old one + # Use -L to dereference symlinks (for homesick/dotfile managers) if [[ -e "${HOME?}/$CONFIG_FILE" ]]; then - cp -a "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.pre-uninstall.bak" + cp -L "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.pre-uninstall.bak" printf '\e[0;33m%s\e[0m\n' "Current ~/$CONFIG_FILE backed up to ~/$CONFIG_FILE.pre-uninstall.bak" fi