Open automator, choose “run shell script” under “utilities” then use the following code.
Save it.
STATUS=`defaults read com.apple.finder AppleShowAllFiles` if [ $STATUS == YES ]; then defaults write com.apple.finder AppleShowAllFiles NO else defaults write com.apple.finder AppleShowAllFiles YES fi killall Finder
You can assign a short cut to the above script like: shift+cmd+.