feat(install): ask for doing a backup of configs that are going to be overwritten

you should do a backup if you appreciate your configs 😛
This commit is contained in:
retrozinndev
2025-10-31 19:10:50 -03:00
parent a894f10edb
commit dc4b3b088a
3 changed files with 54 additions and 4 deletions
+9 -1
View File
@@ -46,7 +46,15 @@ echo "Welcome to the colorshell installation script!"
# Warn user of possible issues
Send_log warn "!! By running this script, you assume total responsability for any issues that may occur with your filesystem"
Send_log warn "Your current Hyprland and kitty configuration will be overwritten, please do a backup if you still want them"
[[ -z $skip_prompts ]] && \
Send_log warn "Your current Hyprland and kitty configuration will be overwritten, accept the backup prompt if you still want them"
[[ -z $skip_prompts ]] && \
Ask "Do you want to backup what is going to be modified/overwritten?"
[[ $answer == y ]] || [[ $skip_prompts ]] && \
Backup_config $repo_directory
[[ -z "$skip_prompts" ]] && \
Ask "Do you want to start the shell installation?"
+39
View File
@@ -92,6 +92,45 @@ function Is_installed() {
return 1
}
# -------------
# Interactively backup user dotfiles that ovewritten by colorshell
# param $1: colorshell repository directory
# -------------
function Backup_config() {
bkp_dir="$HOME/config.bkp"
repo_dir=${1:-"."}
Send_log "Creating backup in $bkp_dir"
if [[ -d $bkp_dir ]]; then
Send_log "Found existing backup in $bkp_dir!"
Ask "Would you like to move it to trash/override it?"
if [[ $answer == "y" ]]; then
echo "Moving previous backup is goning to be moved to trash"
trash-put $bkp_dir || (mkdir -p "$XDG_DATA_HOME/Trash" && \
mv $bkp_dir "$XDG_DATA_HOME/Trash/$(basename $bkp_dir)")
else
echo "Ok, quitting backup because it already exists"
return 1
fi
fi
# Make backup of existing configurations
mkdir -p $bkp_dir
for dir in $(basename `ls -A $repo_directory/config`); do
if [[ -d "$CONFIG_DIR/$dir" ]]; then
echo "-> backuping $dir"
cp -r "$CONFIG_DIR/$dir" $DOTFILES_BACKUP_DIR
else
Send_log "$dir not found, skipped"
fi
done
Send_log "backup has been finished"
}
# -------------
# Ask the user to choose a number from the provided list
# Input answer is exported as $answer
+6 -3
View File
@@ -55,14 +55,17 @@ echo "This is colorshell's update script"
if Is_installed; then
Send_log "colorshell installation found"
else
Send_log "no colorshell installation found, please install it before updating"
Send_log err "no colorshell installation found, please install it before updating"
exit 1
fi
# Warn user of possible issues
Send_log warn "!! By running this, you assume total responsability for issues that can occur to your filesystem"
Send_log warn "!! By running this, you assume total responsability for \
issues that can occur to your filesystem"
Send_log "The updater will only change shell configs, like hypr/shell \
and kitty/kitty.conf, not user ones(hypr/user, kitty/user.conf)"
[[ -z "$skip_prompts" ]] && \
[[ -z $skip_prompts ]] && \
Ask "Do you want to update colorshell?"
if [[ "$answer" == y ]] || [[ "$skip_prompts" ]]; then