Skip to content

Instantly share code, notes, and snippets.

@peterdemartini
Last active September 23, 2025 06:35
Show Gist options
  • Save peterdemartini/4c918635208943e7a042ff5ffa789fc1 to your computer and use it in GitHub Desktop.
Save peterdemartini/4c918635208943e7a042ff5ffa789fc1 to your computer and use it in GitHub Desktop.
Exclude node_modules in timemachine
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
@kepoorz
Copy link

kepoorz commented Jul 31, 2025

i was searching for a solution and this helped me a lot so im gonna drop a little here.

for fish and showing logs for what you're adding

find . -type d -maxdepth 3 -name 'node_modules' | while read -l line
     echo "Excluding: $line"
     tmutil addexclusion "$line"
end

and to check what you added

find . -type d -maxdepth 3 -name 'node_modules' | while read -l line
    tmutil isexcluded "$line"
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment