summaryrefslogtreecommitdiff
path: root/bin/hstow
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-12-03 16:12:45 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-12-03 23:15:32 -0700
commit1017e90e4b117df5871fe6447fb6587a5bd98cb5 (patch)
treeae248f95a442f4d710c357d4dd39a4890666b152 /bin/hstow
parent37815c8bda4a88df6103d68e1b117a68bd24da19 (diff)
downloaddotfiles-1017e90e4b117df5871fe6447fb6587a5bd98cb5.tar.gz
speed up hstow's restowing, restow in post_update actions
Diffstat (limited to 'bin/hstow')
-rwxr-xr-xbin/hstow12
1 files changed, 10 insertions, 2 deletions
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