From 60c91d041adaf40372271a2d792b9b0e96b058c7 Mon Sep 17 00:00:00 2001 From: Yasmin Teles Date: Sat, 9 Mar 2024 15:51:16 -0300 Subject: [PATCH] feat: add uninstall script --- Makefile | 7 +++++-- README.md | 21 ++++++++++++++++++++- uninstall.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 uninstall.sh diff --git a/Makefile b/Makefile index d06733a..65f809d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help del ssh backup +.PHONY: help check_clean del ssh backup help: ## Show help. @printf "A set of environment management commands.\n" @@ -7,7 +7,10 @@ help: ## Show help. @printf "\nThe Commands are:\n\n" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\t\033[36m%-30s\033[0m %s\n", $$1, $$2}' -del: ## Delete your development environment. +check_clean: + @echo -n "Are you sure you want to remove all configurations? [y/N] " && read ans && [ $${ans:-N} = y ] + +del: check_clean ## Delete your development environment. @echo "Deleting all dotfiles, applications, and folders..." @stow --dotfiles -D git ssh brew zsh @rm -rf ~/Projects diff --git a/README.md b/README.md index 6d60f77..9eff319 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ These are my dotfiles. Insert this into a macOS Terminal or Linux shell prompt. The script will detail its actions and then halt before executing them. ```bash - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/HEAD/install.sh)" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/main/install.sh)" ``` ## Post-Installation @@ -38,6 +38,25 @@ A set of environment management commands is available at `Makefile`. To access t make help ``` +## Uninstalling Environment Configurations + +This script is designed to remove all configurations of your environment. **Please proceed with caution** as this action is irreversible. + +### Instructions + +Enter this command into a macOS Terminal or Linux shell prompt. The script will outline its actions. + +```bash + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/YasminTeles/dotfiles/main/uninstall.sh)" +``` + +### Important Notes + +> [!CAUTION] +> Ensure you have **backups** of any important configurations before running this script. + +By following these steps, you can safely remove all configurations of the environment as needed. + ## License This project is licensed under the [MIT License](LICENSE). diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..93dc2ef --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Tells the shell script to exit if it encounters an error +set -e + +# Print a step description +TOTAL_STEPS=5 +STEP=1 +function step_msg { + printf "\n[$STEP/$TOTAL_STEPS] $1...\n"; + ((STEP++)) +} + +echo "This script will remove all configurations of the environment." +read -p "Are you sure you want to proceed? (y/n) " CONFIRM + +if [[ $CONFIRM == [yY] || $CONFIRM == [yY][eE][sS] ]] +then + printf "\nPlease wait! Proceeding with the removal of all configurations...\n" + + # -- Symlinks ---------------------------------------------------------------- + step_msg "Removing all symlinks" + cd ~/.dotfiles && stow --dotfiles -D git ssh brew zsh + + # -- Project folder ---------------------------------------------------------- + step_msg "Removing the Project directory" + rm -rf ~/Projects + + # -- SSH Key ----------------------------------------------------------------- + step_msg "Removing SSH Keys" + rm -rf ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub + + # -- Productivity Apps ------------------------------------------------------- + step_msg "Removing all productivity apps" + rm -rf ~/.oh-my-zsh + brew uninstall --force $(brew list) + + # -- Dotfiles ---------------------------------------------------------------- + step_msg "Removing Dotfiles directory" + rm -rf ~/.dotfiles + +# -- Happy end ----------------------------------------------------------------- + printf "\nAll configurations have been removed." + +else + printf "\nOperation cancelled." +fi + +printf "\nHave a nice day!\n" +