There are many situations when you need to view hidden files on Mac. Especially if you are doing software development as there are a lot of files that start with a
. (dot), such as the
.gitignore file, as any file that starts with a dot is hidden automatically. This was especially annoying for me when I realized my Eleventy configuration file
.eleventy.js was missing because Finder does not copy hidden files.
Depending on your need, you can change the finder configuration to always show hidden files in all situations, or you can use a secret keyboard shortcut to toggle displaying them on or off.
Show Hidden Files in Finder with a Keyboard Shortcut
When in Finder and at the location where you want to view hidden files, simply hold down
⌘ Command, Shift, and . (period) keys all at once and the hidden files will immediately be shown. Want to hide them again, just use the keyboard shortcut again.
⌘ Command Shift .
Configure Finder to Always Show Hidden Files
Open up Terminal and copy and paste the following to show hidden files:
defaults write com.apple.Finder AppleShowAllFiles true && killall Finder
If you want to hide the hidden files again, just run:
defaults write com.apple.Finder AppleShowAllFiles false && killall Finder
Show Hidden Files within Terminal
You are likely very familiar with the
ls command to list files when navigating at the terminal prompt, but you may not be aware that hidden files are also hidden by default with this command. To see hidden files in Terminal, you must include the
-a flag when using ls.
stevesinchak@tweaks ~ % ls
The same directory with the
ls -a flag.
stevesinchak@tweaks ~ % ls -a