From b3fe75f7faabed3453d051c3ba9f51663eea11bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dias?= Date: Sun, 4 Aug 2024 15:51:07 -0300 Subject: [PATCH] :sparkles: feat: add verification for the backup dir --- apply.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apply.sh b/apply.sh index a3d6574..b187b86 100755 --- a/apply.sh +++ b/apply.sh @@ -12,6 +12,7 @@ printf "\n" CONFIG_DIR="$HOME/.config" DOTFILES_DIRS=("hypr" "waybar" "swaync" "wlogout" "wofi") DOTFILES_BACKUP_DIR="$HOME/hyprland-dotfiles-bkp" +TRASH_DIR="$HOME/.local/share/Trash/files" echo "Welcome to my dotfiles installation script!" @@ -22,7 +23,22 @@ function Backup_previous_dotfiles { echo "Making backup before installing dotfiles..." echo "[info] Creating backup dir in $DOTFILES_BACKUP_DIR" - mkdir $DOTFILES_BACKUP_DIR + + if [[ -d $DOTFILES_BACKUP_DIR ]] + then + echo "Looks like the backup directory already exists!" + echo -n "Would you like to override it with the current configuration? (Will be moved to Trash dir) [y/n] " + read override_backup + printf "\n" + + if [[ $override_backup = "y" ]] || [[ $override_backup = "yes" ]] + then + echo "Ok! The backup folder will be ovewritten with the current user configuration." + mv -f $DOTFILES_BACKUP_DIR $TRASH_DIR + fi + else + mkdir $DOTFILES_BACKUP_DIR + fi # Make backup of existing configurations for dir in ${DOTFILES_DIRS[@]}; do