Nov 19

If you frequently need to show/hide hidden files on OSX, here’s what I find is the easiest way so you don’t have to do a google search every time to remind yourself of the syntax.

Create a file called ‘showHiddenFiles’
in Terminal, type:


chmod +x /path/to/showHiddenFiles

Make sure the location is on your path. I just use /usr/local/bin since it’s already on my path.

Edit that file with these contents:


#!/bin/sh
defaults write com.apple.finder AppleShowAllFiles $1
killall Finder

Now whenever you want to hide/show hidden files, just launch Terminal and type:

% showHiddenFiles true
– or –
% showHiddenFiles false

And don’t forget you can just type the first few letters (i.e. ‘showH’), then hit TAB and Terminal should auto-complete the file name for you. Then you can just add ‘true’ or ‘false’.

Post to Twitter

2 Responses to “Shell script to show/hide hidden files on OS X”

  1. dareikel says:

    what’s the purpose of the #!/bin/sh in the file contents?

  2. Imrul says:

    This is the way to inform the OS to run the commands using default shell program.

Leave a Reply

 
preload preload preload