How to stop creating .DS_Store on Mac?
Please install http://asepsis.binaryage.com/ and then reboot your mac.
ASEPSIS redirect all .DS_Store on your mac to /usr/local/.dscage
After that, You could recursively delete all .DS_Store from your Mac.
find ~ -name ".DS_Store" -delete
or
find <your path> -name ".DS_Store" -delete
You should repeat procedure after each major Mac update.
Its is possible by using mach_inject. Take a look at Death to .DS_Store
I found that overriding HFSPlusPropertyStore::FlushChanges() with a function that simply did nothing, successfully prevented the creation of .DS_Store files on both Snow Leopard and Lion.
DeathToDSStore source code
NOTE: On 10.11 you can not inject code into system apps.
NOTE: "Asepsis is no longer under active development and supported under OS X 10.11 (El Capitan) and later."
Here's a comprehensive review of your options. Asepsis (the second solution mentioned) seems to be what you're looking for, it re-routes .DS_Store creation to a unified cache instead of being located on every folder.