TextMate creates temporary files, and doesn't delete them!
I'm using TextMate and each time I edit a file, a copy like ._file is created.
This is driving my crazy and last time it create a serious problem on some app I'm using which believe it that file was a new component and as it could not load it ( because it was NOT a new component ) it crashed.
How can I get rid of this temporary files?
._file
files aren't actually temporary files but a file that holds the resource fork data for Mac OS X. Mac OS X will create this for files that are being stored on a non-HFS system in order to preserve the metadata.
However you can run the following command to disable the creation by TextMate of a resource fork:
defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1
If you have the latest version (build 1589 - Nov. 23rd, 2009) it also allows you to enter an array of file systems instead if you still want the metadata on other drives (say yes to your internal, and no to any network or non-HFS drive):
defaults write com.macromates.textmate OakDocumentCustomFSMetaData '( afpfs, nfs, msdos, hfs )'
These ._
, or dot-underscore files are created by Mac OSX as an alternate way of storing Extended Attributes on a filesystem that doesn't support those natively.
Although technically and historically something completely different, recent versions of Mac OSX treat Resource Forks more/less as if they were Extended Attributes, at least from a user-perspective. See this stackexchange question for more (technical) information on (Extended) File Attributes, resourceforks and streams etc.
You can learn about the presence of Extended Attributes on files using ls -l
on the commandline. Files with extended attributes have a @
appended to their name. Doing ls -l@
will also list the names of these attributes. And finally, doing xattr -l <filename>
prints the attribute-names and -data of the specified file (hex-editor style). See below for examples.
$ > ls -la ~/Library/Fonts
total 225448
drwx------+ 536 arri staff 18224 Jun 17 04:57 .
drwx------@ 101 arri staff 3434 Aug 18 16:33 ..
-rwxr-xr-x@ 1 arri staff 45 Aug 12 2010 04b-03.suit
-rwxr-xr-x 1 arri staff 19492 Mar 25 2003 04b03.ttf
-rw-r--r--@ 1 arri staff 54544 Apr 24 2012 27344.ttf
...
$ > ls -la@ ~/Library/Fonts
total 225448
drwx------+ 536 arri staff 18224 Jun 17 04:57 .
drwx------@ 101 arri staff 3434 Aug 18 16:33 ..
com.apple.FinderInfo 32
-rwxr-xr-x@ 1 arri staff 45 Aug 12 2010 04b-03.suit
com.apple.FinderInfo 32
com.apple.ResourceFork 20314
-rwxr-xr-x 1 arri staff 19492 Mar 25 2003 04b03.ttf
-rw-r--r--@ 1 arri staff 54544 Apr 24 2012 27344.ttf
com.apple.metadata:kMDItemDownloadedDate 53
com.apple.metadata:kMDItemWhereFroms 166
$ > xattr -l ~/Library/Fonts/04b-03.suit
com.apple.FinderInfo:
00000000 46 46 49 4C 44 4D 4F 56 01 00 00 00 00 00 00 00 |FFILDMOV........|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020
com.apple.ResourceFork:
00000000 00 00 01 00 00 00 4E F2 00 00 4D F2 00 00 00 68 |......N...M....h|
00000010 C9 0B 1A C9 23 08 03 1A C9 0B 1A C9 23 02 1A C9 |....#.......#...|
...
Note that next to HFS Plus, many other filesystems support Extended Attributes as well, they just don't always play nice with Mac OSX out of the box.
One example would be for instance an SMB-mounted, remote Windows filesystem (NTFS). Both the NTFS filesystem, as the SMB-'protocol' (and Mac-implementation of it) support Extended Atributes, but in that context they're called Named Streams. This feature is often disabled by default, but can easily enabled as described here.