When using Finder, OSX generates some hidden files. These files are usually fine in the context of OSX, but may not be appropriate on remote servers, mounted drives, or in git repos.
._* files, as well as the
You could spend money on software like BlueHarvest to clean these files up automatically, or you could create a single alias that does it for free:
alias sweep="find . -name .DS_Store -type f -delete ; find . -type d | xargs dot_clean -m"
The first part (
find . -name .DS_Store -type f -delete) will simply find all .DS_Store files (recursively) and delete them.
The second part (
find . -type d | xargs dot_clean -m) uses an OSX builtin command called
dot_clean which will clean up
._* files (which are called AppleDouble files and contain resource forks).
dot_clean does not work recursively, so first we list all subdirectories underneath the current directory with
find . -type d, then pipe the list to
xargs which runs
dot_clean -m on each item in the list.
If you'd also like to remove
.Trashes directories, you could add one more command:
alias sweep="find . -name .DS_Store -type f -delete ; find -name .Trashes -type d -delete ; find . -type d | xargs dot_clean -m"
.Trashes included, you might need to call the alias using
Now, whenever you need to clean things up, just