TextMate's Extended Attributes

TextMade is my current favorite text editor. But, while editing some files on our main Drupal server, I noticed it was leaving some ghost files around. The filenames were all prefixed with "._" so they didn't show up in the Finder, or in normal ls -l lists. From the text that was displayed in Drupal, it looks like it was storing things like cursor position and text selection in a file that was edited by TextMate.

Normally not a big deal, but Drupal was picking them up as potential themes and modules, and dutifully listing them, and choking on the included cursor/selection info. I did some poking around and found the answer (sometimes, RTFM really helps, and TextMate has a really good built-in manual). Here's the scoop:

19.4 Extended Attributes (Metadata)

Starting with Tiger, OS X supports setxattr and friends.

TextMate makes use of extended attributes to store the carets position, bookmarks, what text is folded and is likely to make further use of extended attributes in the future.

For filesystems which do not natively support extended attributes (like network mounted disks), OS X instead stores the extra information in a file named ._«filename», where «filename» is the name of the original file.

Since not all users think that this extra (hidden) file is worth having in order for TextMate to remember state, it is possible to disable the use of extended attributes by quitting TextMate and running the following from the shell:

defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1

So, the strange files, named "._whateverFileIWasEditing.php" are created by TextMate when editing files on a non MacOSX-Tiger system. Like, say, a MacOSX Panther Server volume mounted via Appleshare. Easy fix, but it probably could have been a checkbox rather than a hidden defaults value.

See Also

comments powered by Disqus
Last updated: November 30, 2023