From 3dcc61847bd85267b652cb04f9bd5d840b059b3b Mon Sep 17 00:00:00 2001 From: hesam-init Date: Sun, 24 Mar 2024 14:23:59 +0330 Subject: [PATCH] fix: unstow shell --- scripts/utils/helpers.sh | 6 +++--- stow.sh | 31 ++----------------------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/scripts/utils/helpers.sh b/scripts/utils/helpers.sh index fc92301..bb9acc2 100755 --- a/scripts/utils/helpers.sh +++ b/scripts/utils/helpers.sh @@ -23,11 +23,11 @@ delete_symlinks() { return 1 fi - for config in $source_dir/*; do + for config in "$source_dir"/* "$source_dir"/.*; do config_name=$(basename $config) - target_config=$target_dir/$config_name + target_config="$target_dir/$config_name" - if [ -e $target_config ]; then + if [ -e "$target_config" ]; then rm -rf $target_config echo "Removed: $target_config" else diff --git a/stow.sh b/stow.sh index 1f6510d..5a8cb51 100755 --- a/stow.sh +++ b/stow.sh @@ -29,7 +29,7 @@ stow_shortcuts() { stow_dotfiles() { create_symlinks $DOTFILES_DIR ~/.config - create_symlinks $SHELL_DIR ~/ + create_symlinks $SHELL_DIR ~ log "Dotfiles stowed successfully!" } @@ -47,35 +47,8 @@ stow() { stow_hyprland } -unstow_shell() { - for config in $SHELL_DIR/.*; do - if [ -f $config ]; then - local file_name=$(basename $config) - local target_file=~/$file_name - - if [ -e $target_file ]; then - rm $target_file - echo "Removed: $target_file" - else - echo "Not found: $target_file" - fi - - elif [ -d "$config" ]; then - local folder_name=$(basename $config) - local target_folder=~/$folder_name - - if [ -e $target_folder ]; then - rm -rf $target_folder - echo "Removed: $target_folder" - else - echo "Not found: $target_folder" - fi - fi - done -} - unstow() { - unstow_shell + delete_symlinks $SHELL_DIR ~ delete_symlinks $DOTFILES_DIR ~/.config delete_symlinks $SHORTCUTS_DIR ~/.local/share/applications delete_symlinks $HYPRLAND_DIR ~/.config