Quickly toggle hidden files in macOS's Finder

By default macOS’s Finder will not show hidden files. This can be overridden using the defaults command line utility and restarting Finder.

$ defaults write com.apple.finder AppleShowAllFiles -bool TRUE
$ killall Finder

However, this will always show all hidden files until the above is undone by replacing TRUE with FALSE. This looks messy and may not be what you want and having to retype the above snippet every time is not very convenient.

As it turns out, since macOS Sierra there is a keyboard shortcut that will toggle the visibility of hidden files and folders:
Shift +  Command + . (full stop). Strangely this very useful shortcut is not mentioned on Apple’s Mac keyboard shortcuts page.

Update: The hidden .DS_Store files that Finder creates in every folder it enters, never show up when asking it to show hidden files.