Easily Add a Keyboard Shortcut to Reveal Hidden Files in Mac OS X

In an earlier tutorial, we have shown you how you can reveal the hidden files in Mac OS X, via the terminal. For those who need to access the hidden files frequently, but hate to use the terminal every time to toggle the visibility of the files, how about setting a keyboard shortcut so you can quickly reveal hidden files with a single press of a key?

To make this work, we have to create a service (in Automator) to run the command and then assign a shortcut for this service.

Note: The following method is tested and working on Mac OS X Yosemite. There are a few reports stating that it might not work in 10.8 (OS X Mountain Lion) and below. We have no way to verify that, so if you are using an older version of OS X, follow this at your own risk.

Creating a service to run the reveal hidden files command

In OS X, open Automator (Applications -> Automator). It will prompt you to choose a type for your new automation. Select “Service.”


In the left most pane, select Utilities. In the center pane, select “Run AppleScript,” and drag it to the Workflow area.


In the Workflow area, first select “no input” for the “Service receives” dropdown field. Next, change the all application field to “Finder.”


In the AppleScript section, replace the line (* Your script goes here *) with this:

set newHiddenVisiblesState to "YES"
        set oldHiddenVisiblesState to do shell script "defaults read com.apple.finder AppleShowAllFiles"
        if oldHiddenVisiblesState is in {"1", "YES"} then
            set newHiddenVisiblesState to "NO"
        end if
    end try
    do shell script "defaults write com.apple.finder AppleShowAllFiles " & newHiddenVisiblesState
    tell application "Finder"
        set theWindows to every Finder window
        repeat with i from 1 to number of items in theWindows
            set this_item to item i of theWindows
            set theView to current view of this_item
            if theView is list view then
                set current view of this_item to icon view
                set current view of this_item to list view
            end if
            set current view of this_item to theView
        end repeat
    end tell

script credit: Ask Different

Lastly, save this (File -> Save) with the name “ToggleHidden” (or any other name that you desire).


To test if the ToggleHidden service is working, open Finder and go to the menu (Finder -> Services) and select the “ToggleHidden” service.


If it works fine, all the hidden files should show up in the Finder. Click on it again, and the hidden files should disappear.

Assigning keyboard shortcut to ToggleHidden

The last step to complete this tutorial is to assign a keyboard shortcut to this service. Go to “System Preferences -> Keyboard -> Shortcuts.” In the left pane, select “Services.” In the right pane, scroll down until you see the “ToggleHidden” entry.


Select the “ToggleHidden” entry and click the “add shortcut” text. You can now add a keyboard shortcut for this service. For this tutorial, I set “Ctrl + Shift + H.” Just for your info, most Linux distros are using “Ctrl + H” to toggle the visibility of hidden files.

That’s it.


For most users, most of the time there won’t be any need to access the hidden files. But for those who need to, revealing the hidden files via the terminal can be a troublesome task, not to mention that you have to remember the command to do it. Setting a keyboard shortcut for this task will make things much easier and definitely make you more productive.

Let us know in the comments if you have any questions.


Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox