Skip to content

Instantly share code, notes, and snippets.

@cognivator
Created April 4, 2016 22:45
Show Gist options
  • Save cognivator/4bcb3dc870ce000af478c4ae8b337260 to your computer and use it in GitHub Desktop.
Save cognivator/4bcb3dc870ce000af478c4ae8b337260 to your computer and use it in GitHub Desktop.
Prevent OSX clutter on external storage
#!/bin/bash
# protect an ext drive (USB, memcard, etc) from the following files:
# .Spotlight-V* (Spotlight index)
# .Trashes (Deleted files)
# .fseventsd/* (journaling)
# .DS_Store (finder prefs... not implemented, yet)
# run this from the root of the drive that should be protected
echo "Before protection:"
ls -al
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
chmod 444 .fseventsd/no_log .fseventsd .metadata_never_index .Trashes
echo "After protection:"
ls -al
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment