forked from Shinonome/dots-hyprland
first steps for fixing and improving update-dots
This commit is contained in:
+13
-9
@@ -44,7 +44,7 @@ cat << 'EOF'
|
|||||||
| |
|
| |
|
||||||
| This script will update your dotfiles (.config, .local, etc) by retrieving the latest version |
|
| This script will update your dotfiles (.config, .local, etc) by retrieving the latest version |
|
||||||
| from the Git repository and then replacing the old config files with the updated ones. |
|
| from the Git repository and then replacing the old config files with the updated ones. |
|
||||||
| To preserve your customizations, it will ask you if you wanna keep some modified |
|
| To preserve your customizations, it will ask you if you wanna keep some customized |
|
||||||
| files untouched. |
|
| files untouched. |
|
||||||
| |
|
| |
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
@@ -63,18 +63,18 @@ current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|||||||
|
|
||||||
# fetch the latest version of the repository
|
# fetch the latest version of the repository
|
||||||
if ! git fetch; then
|
if ! git fetch; then
|
||||||
echo -e "${RED}Failed to fetch the latest version of the repository. Exiting.${RESET}"
|
echo -e "${RED}Failed to fetch the latest version of the repository. Exiting...${RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if there are any changes
|
# Check if there are any changes
|
||||||
if [[ $(git rev-list HEAD...origin/"$current_branch" --count) -eq 0 ]]; then
|
if [[ $(git rev-list HEAD...origin/"$current_branch" --count) -eq 0 ]]; then
|
||||||
echo -e "${GREEN}Repository is already up-to-date. Do not run git pull before this script. Exiting.${RESET}"
|
echo -e "${GREEN}Repository is already up-to-date. Do not run git pull before this script. Exiting...${RESET}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo -e "${CYAN}Excluding files and folders: ${excludes[@]}${RESET}"
|
echo -e "${CYAN}Excluding files and folders that remain untouched: ${excludes[@]}${RESET}"
|
||||||
|
|
||||||
# Then check which files have been modified by the user since the last update to preserve user configurations
|
# Then check which files have been customized by the user since the last update to preserve user configurations
|
||||||
modified_files=()
|
modified_files=()
|
||||||
|
|
||||||
# Find all files in the specified folders and their subfolders
|
# Find all files in the specified folders and their subfolders
|
||||||
@@ -99,12 +99,12 @@ echo
|
|||||||
|
|
||||||
# Output all modified files
|
# Output all modified files
|
||||||
if [[ ${#modified_files[@]} -gt 0 ]]; then
|
if [[ ${#modified_files[@]} -gt 0 ]]; then
|
||||||
echo -e "${MAGENTA}The following files have been modified since the last update:${RESET}"
|
echo -e "${MAGENTA}Customized Files detected: ${RESET}The following files have been customized by you or your system:"
|
||||||
for file in "${modified_files[@]}"; do
|
for file in "${modified_files[@]}"; do
|
||||||
echo -e "${BLUE}$file${RESET}"
|
echo -e "${BLUE}$file${RESET}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
read -rp "No files found that have been modified since the last update. All files will be replaced. Are you sure you want to continue? [Y/n] " REPLY
|
read -rp "${YELLOW}No files detected that have been customized since the last update. All files will be replaced. Are you sure you want to continue? [Y/n] ${RESET}" REPLY
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||||
echo -e "${RED}Exiting.${RESET}"
|
echo -e "${RED}Exiting.${RESET}"
|
||||||
@@ -158,7 +158,7 @@ case $REPLY in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "${GREEN}Keeping every modified file${RESET}"
|
echo -e "${GREEN}Keeping every customized file${RESET}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -190,8 +190,9 @@ if ! git pull; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
echo -e "${GREEN}New dotfiles have been copied. Cleaning up temporary folder.${RESET}"
|
echo -e "${GREEN}New dotfiles have been copied. Cleaning up temporary folder...${RESET}"
|
||||||
rm -rf "$temp_folder"
|
rm -rf "$temp_folder"
|
||||||
|
echo -e "${GREEN}Done. You may exit now.${RESET}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -209,3 +210,6 @@ for folder in "${folders[@]}"; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo -e "${GREEN}Done. You may exit now.${RESET}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user