For what it is worth, I have the following in my .bash_profile for doing this, similar to @SwankyLegg
togglehidden() {
STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ $STATUS == TRUE ];
then
defaults write com.apple.finder AppleShowAllFiles FALSE
else
defaults write com.apple.finder AppleShowAllFiles TRUE
fi
osascript -e 'tell app "Finder" to quit'
sleep 1
osascript -e 'launch app "Finder"'
}
so I can call it from the Terminal. (NB, if you run it on a machine where AppleShowAllFiles
has never been set, you'll get a complaint the first time you run it,ala:
XXXXXXXXX defaults[2228:124111]
The domain/default pair of (/Users/xxx/Library/Preferences/com.apple.finder, AppleShowAllFiles) does not exist
but everything's gonna be OK. I believe that it lives in the NSGlobalDomain
by default, but this sets it in the user's. )