Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Realizing that it is possible to change the prefs check-off box in Finder to hide the Hard Drive icon, how would you do this from the command line interface? I.e. what and/or where is the CLI command that emulates the check-off box?

share|improve this question

3 Answers 3

I think you're looking for SetFile's invisible attribute which can be used on files and folders:

SetFile -a V /path/to/folder

SetFile is not included by default in versions prior to Snow Leopard, but you can get it from the Apple developers kit.

share|improve this answer

For hiding the Hard Drive you can modify Finder's preferences using the defaults command.

Specifically you would want to run:

defaults write com.apple.finder ShowHardDrivesOnDesktop -bool NO

and relaunch the Finder (using killall Finder for example)

For hiding files in general from Finder you can either have . in front of the filename (eg. .hidden Folder), by turning on the invisible flag using SetFile, or using chflags.

/usr/bin/SetFile -a V /PATH/TO/FILE/OR/FOLDER

chflags hidden /PATH/TO/FILE/OR/FOLDER

To reverse:

SetFile -a v /PATH/TO/FILE/OR/FOLDER

chflags nohidden /PATH/TO/FILE/OR/FOLDER

SetFile is installed by default in Snow Leopard but previous versions required you to install the Developer Tools.

share|improve this answer
    
Your one works if you state NO rather than YES (OP wanted to hide not show) –  Rob Cowell Jan 13 '10 at 18:05
    
instead of setfile which requires snow leopard, you can use 'chflags hidden /path/to/file'. –  yanokwa Jan 13 '10 at 18:38
    
Fixed and added bits about chflags. Thanks, I forgot about chflags. –  Chealion Jan 14 '10 at 16:15

Disclaimer : This is not the right answer yet, but hopefully someone can build upon it to make it work :-

defaults write ~/Library/Preferences/com.apple.finder.plist ShowHardDrivesOnDesktop -bool false && sudo killall Finder
share|improve this answer
    
Chealion's version is better (if you say NO rather than YES) - the difference seems to be not specifying a specific path to the plist and just writing to com.apple.finder –  Rob Cowell Jan 13 '10 at 18:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.