I prepared a little bash script to toggle the visibility of my hidden OS X files.
if (defaults write com.apple.finder AppleShowAllFiles FALSE); then
defaults write com.apple.finder AppleShowAllFiles TRUE
elif (defaults write com.apple.finder AppleShowAllFiles TRUE); then
defaults write com.apple.finder AppleShowAllFiles FALSE
fi
killall Finder
When hidden files are invisible, the script successfully makes them visible but afterwards, when I re-run the script to make the hidden files invisible again, it fails and does nothing.
Where am I going wrong?
#!/usr/bin/env bashand the second line toset -x).