This question is very similar to Is it possible to always show hidden/dotfiles in Open/Save dialogs?. How to show hidden files and folders in finder? is also related. However, I don't want to always show them, and that's what defaults write ... AppleShowAllFiles ... does.

Rather, I want to switch it on when needed. I'm trying to open .bash_profile, so I need it now:

enter image description here

Linux and Gnome allow us to CTRL+H to toggle between showing and hiding hidden files. But Gnome hotkeys don't work on OS X (which is expected).

For completeness, .bash_profile does exist in the home directory:

$ ls ~/.bash_profile 

A related question... As can be seen above, typing the filename in Finder (or is it Spotlight) search did not work. I tried to right click to get a context menu in the File Open dialog in hopes of checking a box like "show all files". And I tried the View menu looking for a "show all files" with the File Open dialog open.

Why is this hidden away somewhere? What purpose does it serve to not allow a user to easily open a file?


⌘ CMD+⇧ SHIFT+. reveals hidden files in Finder and Open/Save dialogs.

You can also press ⌘ CMD+⇧ SHIFT+G and type the path to the hidden folder, just like in Terminal (⇥ TAB autocompletion also works).

Editing hidden files can be dangerous if you don't know what you're doing.

  • 7
    Works for me in Column view if I change path - go to another drive & back again, etc. - or change view, to icon & back. – Tetsujin May 9 '15 at 12:18
  • 10
    The keyboard shortcut "cmd+shift+." seems to work on a broader scale in Finder in Sierra (not just the Open/Save dialogs), in several views as well. – Niall Nov 11 '16 at 14:01
  • 4
    Wow, can't believe there is a shortcut for this, how oddly specific. Thanks! – Ezekiel Victor May 26 '17 at 23:42
  • 1
    @MateuszSzlosek, Doesn't seem to work for me. cmdshiftG cannot select the hidden file, not unless I first do a cmdshiftdot. It works for you? – Pacerier Aug 15 '17 at 22:39
  • 2
    Ah I get what you mean. So Yes CMD+SHIFT+G won't select hidden file unless you reveal them using CMD+SHIFT+. But You can still navigate to hidden folders using CMD+SHIFT+G without revealing them. Good point! – Mateusz Szlosek Aug 16 '17 at 8:28

Mateusz Szlosek covered the first part. Below is how I have handled the second part for my own use.

In my haste to post my answer, I did not realize the second part has already has been answered. See How to set ⌘ + H to enable show hidden files. What I offer below differs by a dialog informing you of the current status.

I created a service using the Automator application. When I want to toggle the viewing of hidden files, I select "Toggle Hidden Files" from the Finder services submenu as shown below. (Hint: Click image for a better view.)

This will cause either pop shown below to appear.

enter image description here

enter image description here

The steps to create the service are give below.

  1. Open the Automator, select a new document of type Service.
  2. Drag the action "Run Shell Script" to the workflow pane.
  3. Edit the contains to appear as shown below. (Hint: Click image for a better view.)

    The text for the script is repeated below.

    STATUS=`defaults read com.apple.finder AppleShowAllFiles 2>/dev/null`
    if [ "$STATUS" == TRUE ]; then
        STATUS=`osascript -e 'tell app "Finder" to display alert "Finder is showing hidden files." buttons {"Cancel", "Hide"}'`
        STATUS=`osascript -e 'tell app "Finder" to display alert "Finder is not showing hidden files." buttons {"Cancel", "Show"}'`
    if [ "$STATUS" == "button returned:Show" ]; then
        defaults write com.apple.finder AppleShowAllFiles TRUE
        killall Finder
    elif [ "$STATUS" == "button returned:Hide" ]; then
        defaults write com.apple.finder AppleShowAllFiles FALSE
        killall Finder
  4. Save (or move) the Toggle Hidden Files.workflow file to the ~/Library/Services folder.
  5. You may need to relaunch the Finder application in order for the service to appear on a menu.

Update 1

Building off of Mateusz Szlosek's answer, I see the keyboard shortcut ⌘ CMD+⇧ SHIFT+. could be added for my service. Go to System Preferences and click on the Keyboard icon. Select "Services" then "Toggle Hidden Files" under the "General" heading. Replace "none" with the ⌘ CMD+⇧ SHIFT+. keyboard short cut.

  • I did exactly as you've told (there is said file in my ~/Library/Services folder), but to no avail even after restarting the computer. – Walter Oct 25 '16 at 18:03
  • @Walter: I have added the Toggle Hidden Files.workflow to Sourceforge.net. See the site: Toggle Hidden Files. You can download the workflow from there. The instructions for installation are also show at this site. – David Anderson Oct 25 '16 at 19:22


Hidden files are hidden for a reason usually. Use the script below only if you're reasonably sure you know what you're doing. In other words: If you break your system by randomly deleting hidden files, it's your own fault.

Here's the script I use to toggle show/don't show hidden files inside Finder.

(The OSX native shortcut to toggle hidden files in Open/Save dialogues was mentioned by Mateusz Szlosek above already)

The difference between my script and others I've seen so far:

Most scripts don't do anything else after killing Finder. Usually, this means you have to navigate back to the folder you were in originally, since the automatic Finder relaunch doesn't reliably open your last active folder.

The script below instead reopens, and focuses on, your last active folder, i.e. the folder you were in when using the toggle, but now showing (or not showing) hidden files.

I assigned a shortcut to it (cmd+shift+.) and find working with hidden files in Finder a lot more convenient now.

Credit to Tetsujin who posted a script on this site a while ago that I adapted to add the 'reopen last folder' functionality.

on run {input, parameters}
    tell application "Finder"
        set var1 to POSIX path of (target of window 1 as alias)
    end tell
    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
    do shell script "defaults write com.apple.finder AppleShowAllFiles " & newHiddenVisiblesState
    ---- Sleep hack mentioned below. 0.5s minimum, 1-2s safer. Ugly, but (probably) unavoidable.
    do shell script "killall Finder; sleep 0.5s"
    tell application "Finder"
        ---- Close other windows if Finder managed to relaunch already
        if application "Finder" is running then
            close every window
        end if
        open (var1 as POSIX file)
    end tell
end run

To use the script: Open a new workflow in Automator, drag in "Run AppleScript", copy&paste the code above, and save inside your services folder (usually, ~/Library/Services/, afaik).

Attaching a shortcut to execute a script should be covered somewhere else on this site. I limited the scope of my shortcut to Finder alone.

Style remark:

I have to resort to a bit of an ugly hack, using 'sleep' after killing Finder, before manually opening the original folder.

If I don't force this delay, there's a chance OSX relaunched Finder already and opened a folder (not necessarily the last active one, in my experience). Together with my own 'open' command, this can lead to the nasty effect of two (unkillable, even) Finder processes running, and Finder not working anymore at all. If this happens, logging out and back in again fixes it, but it's a waste of time obviously, so I use 'sleep'.

A sleep value of 0.5s works for me, but to be on the safe side, you can slightly increase it (adding a more noticeable delay to the process then).

If someone knows of a way to either suppress the Finder relaunch and unreliable opening of some window after sending the killall signal -- or some other way to get rid of the 'sleep' hack -- I'd be happy to hear it!

You must log in to answer this question.

protected by Community Jul 25 '16 at 16:09

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .