One useful part of owning a Mac is the ability to quickly show and hide hidden files so that you can make quick adjustments. For my own workflow that meant starting a Google search for "Show Hidden Files on Mac" all the time when I needed to see and edit a hidden file, then open a terminal window and paste the command that they provided on the page in order to complete that particular workflow. Not the best and quickest solution I know. So at one point I figured that I would set up an alias for both showing and hiding files quickly using terminal with commands that I could remember easily.
Setting up a Terminal Alias to Show/Hide Hidden Files
A Terminal alias is a shortcut in that allows a user to run one or many commands easily. There are permanent or temporary types of alias and for this case we are going to setup a permanent alias.
- Open Terminal, which is found in Finder > Applications > Utilities
- In your Terminal, paste this:
sudo nano ~/.bash_profile
- Enter your user password, if it requests one in the terminal, then hit enter.
- At the end of the .bash_profile, paste the following two commands:
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder'
- Press ctrl + O and hit return to save the changes.
- Press ctrl + X to exit the file and return to the command line.
You can either refresh your Terminal window to accept the new changes you made or you can close and open another Terminal window. To refresh your Terminal window paste this:
source ~/.bash_profile and hit return.
You should now be able to show and hide hidden files with the alias you inserted above:
hideFiles. This will allow you to easily show hidden files to make an edit to a file or to hide them to clean up the directory listings so you don't have to see everything all the time.