️ perf(replace): minor improvements && clarity

This commit is contained in:
Eshan Roy
2024-11-19 09:18:34 +05:30
parent 4bd1723976
commit 6cdad23399

View File

@@ -1,36 +1,42 @@
#!/bin/bash #!/bin/bash
# Ask the user whether to copy contents from /etc/skel to the Home directory
echo "Copy contents from /etc/skel to Home directory? (Y/n)" echo "Copy contents from /etc/skel to Home directory? (Y/n)"
# shellcheck disable=SC2162 read -r response
read response
# Check if the user agrees (Y or y)
if [[ "$response" == [yY] ]]; then if [[ "$response" == [yY] ]]; then
# Get current date and time to append to backup folder name
time=$(date +%Y.%m.%d-%H.%M.%S)
time=$(date +%Y.%m.%d-%H.%M.%S) # Ensure the ~/.config directory exists, if not, create it
if [ ! -d ~/.config ]; then if [ ! -d "$HOME/.config" ]; then
mkdir ~/.config mkdir -p "$HOME/.config"
fi fi
echo
# shellcheck disable=SC2086
echo "Backing up .config folder to ~/.config-backup-"$time
echo
# shellcheck disable=SC2086 echo
cp -Rf ~/.config ~/.config-backup-$time # Notify user about the backup of .config folder
echo "Backing up .config folder to $HOME/.config-backup-$time"
echo
echo # Backup the current .config folder with a timestamped name
echo "Overwriting existing .config folder with the files from /etc/skel" cp -Rf "$HOME/.config" "$HOME/.config-backup-$time"
echo
# shellcheck disable=SC2086 echo
cp -r /etc/skel/. $HOME # Inform the user that the .config folder will be overwritten
echo "Overwriting existing .config folder with files from /etc/skel"
echo
echo # Copy the contents of /etc/skel to the user's home directory
echo "Task Completed!" cp -r /etc/skel/. "$HOME"
echo
echo
echo "Task Completed!"
echo
else else
echo # User chose not to make any changes
echo "No change!" echo
echo echo "No change made!"
echo
fi fi