How to hide / show files or directories in OS X
more from apple
May 3, 07

There's a utility included in OS X developer tools called SetFile that lets you set all kinds of attributes about files and directories, including visibility. The visibility attribute is what OS X uses to hide things like /var/vm, or /sbin, etc. from regular browsing through Finder windows.

If you have developer tools installed, you can run this from a terminal window to hide a file or directory:

# /Developer/Tools/SetFile -a V [filename]

To show the file again, run the same thing with lowercase "v":

# /Developer/Tools/SetFile -a v [filename]

If you end up using these a lot, I guess you could create aliases like "hide" and "show" which do the command stuff above, like this in bash:

# alias hide='/Developer/Tools/SetFile -a V'
# alias show='/Developer/Tools/SetFile -a v'

That way you could hide and show files more easily, like this:

# hide [filename]
# show [filename]