Skip to content

Instantly share code, notes, and snippets.

@amandeepjutla
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepjutla/16fb89950ea64d43096f to your computer and use it in GitHub Desktop.
Save amandeepjutla/16fb89950ea64d43096f to your computer and use it in GitHub Desktop.
Simple script that toggles visibility of hidden files in OS X. It requires Python 2.7.
#!/usr/bin/env python
# vision
import subprocess
output = subprocess.check_output(
["defaults", "read", "com.apple.finder", "AppleShowAllFiles"])
if "NO" in output:
subprocess.call(["defaults", "write", "com.apple.finder",
"AppleShowAllFiles", "YES"])
subprocess.call(["killall", "Finder"])
print "Hidden files are now visible."
if "YES" in output:
subprocess.call(["defaults", "write", "com.apple.finder",
"AppleShowAllFiles", "NO"])
subprocess.call(["killall", "Finder"])
print "Hidden files are now hidden."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment