Keeping .DS_Store files at bay

.DS_Store files are to Mac what Thumbs.db are to Windows: annoying, meaningless and worst of all, ubiquitous. Whenever you browse to a folder which contains certain magic files or you do something like moving an icon to a certain position, they system will create those files in the folder. Then you happily type in git status, or svn status, when lo and behold! those defiant .DS_Store files are there, waiting to be added to your repository.

So you type this in, frantically:

find . -name ".DS_Store" -delete

and then before it happens again, you edit your .gitignore file (which as the user’s manual helpfully points out, should be in the top level of your working directory) and make sure it contains the following lines:

# Ignore useless stuff
.DS_Store

Or if you’re using subversion, you can set the svn:ignore property:

svn propset svn:ignore .DS_Store .

You may want to make sure there isn’t a previous value for svn:ignore with

svn propget svn:ignore .

and if that’s the case, probably “merge” them so that you don’t lose those values.

While we are on it we could also add Thumbs.db to the list, but since I haven’t used a Windows system for developing in a long time, I don’t need to do that (lucky me!)

ie6 for Android

Comments

  • A question out of curiosity from a linux user: Is it possible to disable the creation of theese files, like it is on windows and their stupis thumbs.db?

  • I think it’s not possible. Apple released an article detailing how to prevent them from being created on network shares, but they still will pollute every usb stick you insert into your computer, for example, apart from the hard disk drives.

  • Too bad… I often see ziped source files with those DS_Store, can be quite irritating heh :-)

  • Yes! that’s the worst thing. Because you can’t say “just ignore .DS_Store files when zipping” as you can with svn/git/etc. You have to be very careful when sending stuff to friends.

    It’s like when there are __MACOS folders in the zip files Mac Os creates. Why?! It’s like an epidemic.

  • I had my own script to get rid of the infamous dot files. But I didn’t know it was easier than what I got. These are my commands:

    sudo find . -name “._*” -depth -exec rm {} \;
    sudo find . -name “.DS_Store” -depth -exec rm {} \;

    I run a script with these lines everytime I’m about to disconnect my Iomega drive when I feed it with movies and music.

    Greetings!

  • Well, my script didn’t take care of deleting ._* files. One might want to consider it too :)

    The external drive scenario is one of the typical cases where mac os pollutes unnecessarily healthy file systems with unrequested rubbish. Ahhh… computers!