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/install.sh b/install.sh index 03b9015..a6fbe8d 100644 --- a/install.sh +++ b/install.sh @@ -11,8 +11,12 @@ function step_msg { } # -- Get some information ----------------------------------------------------- -printf "Please enter some information.\n" -read -p "What is your email? " GIT_EMAIL +if [ "$CI" = true ] ; then + GIT_EMAIL=name@mail.com +else + printf "Please enter some information.\n" + read -p "What is your email? " GIT_EMAIL +fi printf "\nPlease wait! It will configure your environment.\n" @@ -30,6 +34,7 @@ step_msg "Setting up dotfiles" git clone https://github.com/YasminTeles/dotfiles.git ~/.dotfiles cd ~/.dotfiles +rm -rf ~/.gitconfig stow --dotfiles git ssh brew # -- Productivity Apps --------------------------------------------------------- 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" +