Skip to content

Instantly share code, notes, and snippets.

@daniellivingston
Created November 14, 2017 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniellivingston/04ef7d6110e7f8cafe67809106dedba1 to your computer and use it in GitHub Desktop.
Save daniellivingston/04ef7d6110e7f8cafe67809106dedba1 to your computer and use it in GitHub Desktop.
Wipes extended macOS attributes
# Wipe all extended attributes that macOS sets
# Based on the GitHub Gist: kennwhite/reset_osx_attributes.sh
# Add to ~/.bash_profile
# Usage:
# Takes one argument as directory
# If no argument provided, acts on current working dir.
wipe_extended_attributes() {
export dir=`echo $1`
if [[ "$1" != "" ]]; then
dir="$1"
else
dir=`pwd`
fi
echo "Captured directory: $dir"
while true; do
read -p "Would you really like to wipe extended attributes? [y/n] " yn
case $yn in
[Yy]* ) wipe=1; break;;
[Nn]* ) wipe=0; break;;
* ) echo " Please answer yes (y) or no (n).";;
esac
done
if [ $wipe -eq 1 ] ; then
echo ""
echo "WIPING EXTENDED ATTRIBUTES"
# Show all extended attributes
ls -lOe $dir
# Remove no-change attributes
sudo chflags nouchg $dir
# Recursively clear all entended attributes
sudo xattr -rc $dir
# The reset to rational owner & perms
sudo chown -R username:staff $dir
sudo chmod -R a+rw $dir
echo "Done."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment