uninstall: //echo/printf

- Alsö, add implementation note at top.
pull/2039/head
John D Pell 2022-02-15 12:58:55 -08:00 committed by John D Pell
parent 4c5e87e545
commit 0485778117
1 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,8 @@
#!/usr/bin/env bash
#
# Since we're uninstalling, avoid depending on any other part of _Bash It_.
# I.e., hard-code colors (avoid `lib/colors.bash`), &c.
: "${BASH_IT:=${HOME?}/.bash_it}"
CONFIG_FILE=".bashrc"
@ -10,21 +14,19 @@ fi
BACKUP_FILE=$CONFIG_FILE.bak
if [[ ! -e "${HOME?}/$BACKUP_FILE" ]]; then
echo -e "\033[0;33mBackup file ${HOME?}/$BACKUP_FILE not found.\033[0m" >&2
printf '\e[0;33m%s\e[0m\n' "Backup file ~/$BACKUP_FILE not found."
test -w "${HOME?}/$CONFIG_FILE" \
&& mv "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.uninstall" \
&& echo -e "\033[0;32mMoved your ${HOME?}/$CONFIG_FILE to ${HOME?}/$CONFIG_FILE.uninstall.\033[0m"
&& printf '\e[0;32m%s\e[0m\n' "Moved your ~/$CONFIG_FILE to ~/$CONFIG_FILE.uninstall."
else
test -w "${HOME?}/$BACKUP_FILE" \
&& cp -a "${HOME?}/$BACKUP_FILE" "${HOME?}/$CONFIG_FILE" \
&& rm "${HOME?}/$BACKUP_FILE" \
&& echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m"
&& printf '\e[0;32m%s\e[0m\n' "Your original ~/$CONFIG_FILE has been restored."
fi
echo ""
echo -e "\033[0;32mUninstallation finished successfully! Sorry to see you go!\033[0m"
echo ""
echo "Final steps to complete the uninstallation:"
echo " -> Remove the $BASH_IT folder"
echo " -> Open a new shell/tab/terminal"
printf '\n\e[0;32m%s\e[0m\n\n' "Uninstallation finished successfully! Sorry to see you go!"
printf '%s\n' "Final steps to complete the uninstallation:"
printf '\t%s\n' "-> Remove the ${BASH_IT//${HOME?}/\~} folder"
printf '\t%s\n' "-> Open a new shell/tab/terminal"