Showing and Hiding Hidden Files and Desktop Icons in 10.8 #102

Open
cameronmalek opened this Issue Aug 1, 2012 · 19 comments

Comments

Projects
None yet
5 participants

The previous method of showing/hiding hidden files in Finder no longer works for me on 10.8

This, however, does work:

# Show hidden files
defaults write com.apple.Finder AppleShowAllFiles YES; killall -HUP Finder
# Hide hidden files
defaults write com.apple.Finder AppleShowAllFiles NO; killall -HUP Finder

(I also use the -HUP flags on killall to request finder relaunch instead of forcing it to. Unrelated to this issue.)

A nifty way of detecting the OS or for this specific capability may be needed, or just run both old and new commands when the user triggers these in .aliases.

UPDATE: This also affects showing and hiding desktop icons. Click here to skip ahead to the (lack of) solution: #102 (comment)

Contributor

porada commented Aug 1, 2012

I can confirm that the current show/hide alias doesn’t work every time (it’s strange to me that once it works and once doesn’t), but, unfortunately, I can’t say replacing -bool true with YES and -bool false with NO fixes anything.

Oh! I forgot a very important thing. Showing hidden files the old way worked fine for me, but I could not re-hide them until I used the method I mentioned. I'll do some further research on this behavior tomorrow.

Contributor

porada commented Aug 1, 2012

I also played with those two lines; they still work randomly:

defaults write com.apple.Finder AppleShowAllFiles TRUE && killall Finder
defaults write com.apple.Finder AppleShowAllFiles FALSE && killall Finder

I’m currently unable to re-hide my hidden files.

Edit:

$ defaults read com.apple.Finder AppleShowAllFiles
0
$ defaults read NSGlobalDomain AppleShowAllFiles
0

…and yet Finder shows hidden files. It looks to me like it might be a bug.

So if I show hidden files using the YES method, I can't hide them unless I use -bool false. If I show hidden files with the -bool true method, I can't hide them again unless I use the NO method. It appears you can't use the same method of showing/hiding files twice.

Additionally, using the same method twice does seem to work if you wait a little bit between hiding and unhiding your files (approximately 30 seconds after previously issuing the command to hide/unhide, you can toggle hide/unhide again. The only reason the YES/NO method I start out the issue with ever worked, is that it took me thirty seconds to test the -bool true/false method before trying that one. It turns out trying YES/NO within thirty seconds also is inaffective.

Also, once you write to com.apple.Finder within those magic thirty seconds, all you have to do to make the changes take effect is killall Finder again outside of that window of ineffectiveness.

Contributor

porada commented Aug 1, 2012

Doesn’t work for me. I’ve tried every pair of the Cartesian product (YES, -bool true, -int 1 × NO, -bool false, -int 0) so far, and the result is still random.

Make sure you read my most recent comment. I figured it out. It takes thirty seconds (at least for me) before you can kill the Finder to make the most recent write to com.apple.Finder apply.

This seems to be a Mountain Lion bug, and unless someone can think of a clever fix on the dotfiles end, close the issue?

Contributor

porada commented Aug 1, 2012

I still think it’s random: once sleep 30 && killall Finder is all Finder needs, sometimes it just works with sleep 10 && killall Finder.

Owner

mathiasbynens commented Aug 1, 2012

Woah, nice research you guys!

I can confirm that the commands that are currently in .osx seem to work fine in OS X 10.8, as long as you wait (at least?) 30 (?) seconds to restart Finder, i.e.:

# Show hidden files
defaults write com.apple.Finder AppleShowAllFiles -bool true; sleep 30; killall Finder
# Hide hidden files
defaults write com.apple.Finder AppleShowAllFiles -bool false; sleep 30; killall Finder

The above commands have had a 100% success rate in my (limited) testing. Update: Make that 80%. Damn.

FWIW, I’ve filed this as bug #12006110 on bugreport.apple.com. Hopefully it’ll get fixed soon, as there seems to be no reliable workaround.

The only issue with this, in terms of it being a possible fix for dotfiles, is that it makes people wait thirty extra seconds in cases where killing Finder immediately works (when it's been >30 seconds since their last show/hide command). Maybe all .aliases needs is a comment saying to wait thirty seconds between commands.

Owner

mathiasbynens commented Aug 4, 2012

@mogetutu reported (#112) that the “hide desktop” commands are showing this issue as well.

# Hide desktop
defaults write com.apple.finder CreateDesktop -bool false
# Show desktop
defaults write com.apple.finder CreateDesktop -bool true

I've updated the issue name to more accurately reflect the bug and make it easier to find.

thanks to http://forums.macrumors.com/showthread.php?t=1412021 i found out that changing defaults write com.apple.Finder in my Lion script to com.apple.finder fixed the problem for me

Owner

mathiasbynens commented Sep 14, 2012

@Tyler-Anderson I thought they were interchangeable, but indeed, this line in .osx is the only occurrence of com.apple.Finder with a capital F. I’ll change that, if only for consistency.

Wow, that's it! The issue's fixed by changing Finder to finder like @Tyler-Anderson discovered.

Owner

mathiasbynens commented Sep 16, 2012

Holy shit.

joelstein referenced this issue in geerlingguy/Visibility May 20, 2013

Closed

Make it work in Mac OS 10.8 #10

Owner

mathiasbynens commented Oct 22, 2013

Apple responded to my bug report!

Apple Developer Relations22-Oct-2013 11:59 PM

We believe this issue has been addressed in OS X Mavericks GM build 13A603. Please verify with this release, and update this report with your results.

Follow the link below to download build OS X Mavericks from the Mac App Store:

https://itunes.apple.com/us/app/os-x-mavericks/id675248567?mt=12

OS X Mavericks GM Build 13A603
Post Date: October 22, 2013

Contributor

porada commented Oct 22, 2013

🎆

Props for digging this issue out.

There is a special app Funter to show and hide hidden files. It allows to switch files visibility in 1 click ant it`s free to download.

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