From 6cdad233990031948049bc4bb49ad64045803d82 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Tue, 19 Nov 2024 09:18:34 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(replace):=20minor=20i?= =?UTF-8?q?mprovements=20&&=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/local/bin/skel | 54 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/usr/local/bin/skel b/usr/local/bin/skel index ee5bb55..257d5d7 100755 --- a/usr/local/bin/skel +++ b/usr/local/bin/skel @@ -1,36 +1,42 @@ #!/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)" -# shellcheck disable=SC2162 -read response +read -r response +# Check if the user agrees (Y or y) 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) - if [ ! -d ~/.config ]; then - mkdir ~/.config - fi - echo - # shellcheck disable=SC2086 - echo "Backing up .config folder to ~/.config-backup-"$time - echo + # Ensure the ~/.config directory exists, if not, create it + if [ ! -d "$HOME/.config" ]; then + mkdir -p "$HOME/.config" + fi - # shellcheck disable=SC2086 - cp -Rf ~/.config ~/.config-backup-$time + echo + # Notify user about the backup of .config folder + echo "Backing up .config folder to $HOME/.config-backup-$time" + echo - echo - echo "Overwriting existing .config folder with the files from /etc/skel" - echo + # Backup the current .config folder with a timestamped name + cp -Rf "$HOME/.config" "$HOME/.config-backup-$time" - # shellcheck disable=SC2086 - cp -r /etc/skel/. $HOME + echo + # Inform the user that the .config folder will be overwritten + echo "Overwriting existing .config folder with files from /etc/skel" + echo - echo - echo "Task Completed!" - echo + # Copy the contents of /etc/skel to the user's home directory + cp -r /etc/skel/. "$HOME" + + echo + echo "Task Completed!" + echo else - echo - echo "No change!" - echo -fi \ No newline at end of file + # User chose not to make any changes + echo + echo "No change made!" + echo +fi