How to quickly display/recover hidden files in Apple Mac OS X

Mac OS X Quickly Display and Restore Hidden Files 
In Mac OS X, there is a dot "." in front of the file name to hide files. You may have noticed this before, for example, when you copy a file from a mac to a pc, you can see the .DS_Store file, but on the pc it's not hidden. 
These files are hidden by default, which has many benefits, the average user has little need to modify them, while keeping these files visible can clutter the folder. However, occasionally you will find yourself needing to view these hidden files. For example, browsing the UNIX file system, working with .htaccess files, or finding your own hidden files that begin with a ".". The easiest way to show hidden files using Terminal is to use Terminal

Just open a terminal (located in Applications - Utilities), copy the following code into it and press enter 
defaults write com.apple.finder AppleShowAllFiles -bool YES 
Finder needs a restart to apply the changes, in terminal then type 
killall Finder 
and press enter 
to restore Hidden and invisible, enter the following code in the terminal and enter 
defaults write com.apple.finder AppleShowAllFiles -bool NO 
Also Finder needs to restart 
killall Finder 
This method is very simple, but more troublesome. 
In the Open and Save 
dialogs, there is a handy keyboard shortcut to toggle the visibility of hidden files. Press Command+Shift+. (dot) in the active dialog to show hidden files and press again to restore. 
Set keyboard shortcuts 
Although Apple has that handy shortcut key in the Open and Save dialogs, it doesn't in the normal finder window. Fortunately, we can easily set a shortcut key ourselves. 
Open Automator (in the Applications folder) and select Services. Select "Run Shell Script" in the resource library and drag it to the work area on the right. Copy the following code into the text box. 
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 
finally receives the above Service , select "no input" from the drop-down menu, and save the workflow as "Toggle Hidden Files".
Now, if you open the Finder - Services menu, you'll see the "Toggle Hidden Files" option you just made. Now to add keyboard shortcuts, open System Preferences - Keyboard and click the Shortcuts tab. Select the service on the left, then check "Toggle Hidden Files", double-click on the right side of it, and press the shortcut you want to set as. I use Command+Shift+. (dot). 

Set a right-click menu item 
与以上设置快捷键中使用Automator的过程相同,唯一的区别在于,上边提到的那个Service receives,这次选中“文件和文件夹”,并在右边选中Finder。保存。现在,当你在finder中弹出右键菜单时,就会看到“Toggle Hidden Files”选项咯。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988829&siteId=291194637