Skip to content

Instantly share code, notes, and snippets.

@mchogan
Last active December 13, 2015 22:18
Show Gist options
  • Save mchogan/4983029 to your computer and use it in GitHub Desktop.
Save mchogan/4983029 to your computer and use it in GitHub Desktop.
Toggle visibility of hidden files and folders in Mac OS X
# Toggle Hidden File Visibility Automator Service
# 1. Create a new Automator service
# 2. Service receives no input in Finder
# 3. Add an Automator Ask For Confirmation action
# 4. Automator Run Shell Script action with below shell script
# Set the Shell to bin/sh/
is_shown=$(defaults read com.apple.finder AppleShowAllFiles)
if [ $is_shown = "FALSE" ]
then
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
else
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
fi
@omandryk
Copy link

Hi, thanks for script, but it doesn't work on OS X 10.8.4 and shows error: "-: -c: line 4: syntax error near unexpected token 'else' ". When I checked manual for UNIX & Linux Shell Scripting (If & Else), I found that correct is
if [ $is_shown = "FALSE" ]; (added semicolon) and it works fine now.

@salsadeanguila
Copy link

Works perfectly in OS X 10.9.2, thank you!

@ivancucer
Copy link

Works in Yosemite. Special thanks @iCoderman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment