uninstall: cleanup

pull/2039/head
John D Pell 2022-01-28 14:51:28 -08:00 committed by John D Pell
parent 0853724c7d
commit c3de63b787
2 changed files with 16 additions and 21 deletions

View File

@ -28,6 +28,7 @@ bash_it.sh
clean_files.txt clean_files.txt
install.sh install.sh
lint_clean_files.sh lint_clean_files.sh
uninstall.sh
# completions # completions
# #

View File

@ -1,31 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ -z "$BASH_IT" ]; : "${BASH_IT:=${HOME?}/.bash_it}"
then
BASH_IT="$HOME/.bash_it"
fi
case $OSTYPE in CONFIG_FILE=".bashrc"
darwin*) if [[ ! -e ~/.bashrc && -e ~/.bash_profile ]]; then
CONFIG_FILE=.bash_profile # legacy Mac or WSL or just no backup file
;; CONFIG_FILE=".bash_profile"
*) fi
CONFIG_FILE=.bashrc
;;
esac
BACKUP_FILE=$CONFIG_FILE.bak BACKUP_FILE=$CONFIG_FILE.bak
if [ ! -e "$HOME/$BACKUP_FILE" ]; then if [[ ! -e "${HOME?}/$BACKUP_FILE" ]]; then
echo -e "\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m" >&2 echo -e "\033[0;33mBackup file ${HOME?}/$BACKUP_FILE not found.\033[0m" >&2
test -w "$HOME/$CONFIG_FILE" && test -w "${HOME?}/$CONFIG_FILE" \
mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall" && && mv "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.uninstall" \
echo -e "\033[0;32mMoved your $HOME/$CONFIG_FILE to $HOME/$CONFIG_FILE.uninstall.\033[0m" && echo -e "\033[0;32mMoved your ${HOME?}/$CONFIG_FILE to ${HOME?}/$CONFIG_FILE.uninstall.\033[0m"
else else
test -w "$HOME/$BACKUP_FILE" && test -w "${HOME?}/$BACKUP_FILE" \
cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE" && && cp -a "${HOME?}/$BACKUP_FILE" "${HOME?}/$CONFIG_FILE" \
rm "$HOME/$BACKUP_FILE" && && rm "${HOME?}/$BACKUP_FILE" \
echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m" && echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m"
fi fi
echo "" echo ""