Sometimes there is a requirement to view hidden files on your Mac maybe a .htaccess file for example, which wouldn't show in Finder because the file attribute is marked as hidden. To resolve this i will show you how to make OS X show us hidden files.

I will also show you how to hide the hidden files also because you get .DS_Store files and .localized files in every folder and these can become annoying, and we don't always need access to all the hidden files.

To Show hidden OS X files is as follows:

1. Open Terminal found in Finder > Applications > Utilities

2. In Terminal, paste the following;

defaults write com.apple.finder AppleShowAllFiles YES

3. Press return

4. Hold ‘alt’ on your keyboard, then right click on the Finder icon in the dock and click Relaunch.

To Hide hidden OS X files is as follows:

1. Open Terminal found in Finder > Applications > Utilities

2. In Terminal, paste the following;

defaults write com.apple.finder AppleShowAllFiles NO

3. Press return

4. Hold ‘alt’ on your keyboard, then right click on the Finder icon in the dock and click Relaunch.

These commands can become tiresome if you are doing them day in day out. We can remedy this by setting up a simple alias. The next step will guide you through creating the terminal alias and make your life easier.

To Show/Hide hidden files the quicker way

A Terminal alias is a name or shortcut for one or multiple commands. Using an easy to remember alias, we can turn the above four step process into just one.
An alias can be made temporarily (just for the use of one terminal session) or permanently. As we want this to be a shortcut used now and in the future, let’s make it permanent:

1. Open Terminal found in Finder > Applications > Utilities

2. In Terminal, paste the following:

sudo vi ~/.bash_profile

3. Enter your password if required, then hit return

4. Press 'i' on the keyboard to enter insert mode

5. At the bottom of the open .bash_profile file, paste '⌘'&'v' the following:

alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'

6. Below that, paste the following:

alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'

7. Press 'ESC' on the keyboard to exit insert mode

8. Type :wq to write the file to disk and quit

9. In Terminal, type the following to refresh your bash profile:

source ~/.bash_profile

Now that you have the alias's setup then you can show or hide files simply by typing showfiles or hidefiles in terminal.