From 1017e90e4b117df5871fe6447fb6587a5bd98cb5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 3 Dec 2022 16:12:45 -0700 Subject: speed up hstow's restowing, restow in post_update actions --- bin/hstow | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'bin/hstow') diff --git a/bin/hstow b/bin/hstow index 1c640425..5fb58a3a 100755 --- a/bin/hstow +++ b/bin/hstow @@ -131,9 +131,17 @@ stow () { unstow () { cd "$HOME" - dir_pat="^\.$(echo $DIR | cut -c$(echo $HOME|wc -m|tr -d ' ')-)/" + + # For speed, skip directories into which we'll never stow anything. + ignores="$([ -e "$DIR/.hstow-unstow-ignore" ] || exit 0 + while read -r line; do + printf "|./%s/" "$line" + done <"$DIR/.hstow-unstow-ignore")" + + dir_pat=".$(echo $DIR | cut -c$(echo $HOME | wc -m | tr -d ' ')-)/" + dirs_pat="$(echo "^($dir_pat$ignores)" | sed -e 's#\.#\\.#g')" for file in $(find . -type l ! -name . ! -name "$cchars" \ - | grep -v "$dir_pat"); do + | grep -Ev "$dirs_pat"); do if readlink "$file" | grep -Eq '^(\.\./)*\.STOW/'"$NAME/"; then rm "$file" while true; do -- cgit v1.2.3