Skip to content

Instantly share code, notes, and snippets.

@lohenyumnam
Last active February 10, 2018 18:54
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 lohenyumnam/9d664ff3670098c745da2aa5e7270a7b to your computer and use it in GitHub Desktop.
Save lohenyumnam/9d664ff3670098c745da2aa5e7270a7b to your computer and use it in GitHub Desktop.

Create a Toggle Hidden Files Menu Item

  • Launch Automator
  • Select Service as the type of template to use for your new Automator task, and click the Choose button
  • In the Library pane, make sure Actions is selected, then underneath the Library item, click Utilities. This will filter the available workflow types to just those relating to utilities.
  • In the filtered list of actions, click Run Shell Script and drag it to the workflow pane.
  • At the top of the workflow pane are two drop-down menu items. Set the 'Service receives selected' to 'files or folders.' Set the 'in' to 'Finder.'
  • Copy the entire shell script command (all six lines), and use it to replace any text that may already be present in the Run Shell Script box.
STATUS='defaults read com.apple.finder AppleShowAllFiles'
if [ $STATUS == 1 ]
then defaults write com.apple.finder AppleShowAllFiles -boolean FALSE
else defaults write com.apple.finder AppleShowAllFiles -boolean TRUE
fi
killall Finder
  • From the Automator file menu, select "Save," and then give the service a name. The name you select will appear as the menu item. I call mine Toggle Hidden Files.
  • After saving the Automator service, you can quit Automator.

Using the Toggle Hidden Files Menu Item

  • Open a Finder window.
  • Right-click any file or folder.
  • Select Services, Toggle Hidden Files, from the pop-up menu.
  • The Finder will toggle the state of hiding files, causing hidden files and folders to display or be hidden depending on their current condition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment