我当前正在运行OS X(10.9.1),只是在保存对话框中尝试了⌘+ ⇧+ .键盘快捷键,所以效果很好。
我还使用^+ ⌘+ ⇧+ 键盘快捷方式在计算机上设置了AppleScript .,可在需要时在Finder中切换隐藏文件的可见性。这样,我不必手动运行终端命令来显示隐藏文件,而且我可以快速将其关闭以避免意外修改系统文件。我使用FastScripts(在Mac App Store中也有售)来允许我为AppleScript设置键盘快捷键,并将AppleScript放在~/Library/Scripts
文件夹中。
更新资料
我已经更新了我的脚本,以便您不必每次希望显示/隐藏隐藏文件的显示时都将Finder杀死。正如markhunte所指出的,您可以切换Finder窗口的视图状态,这将刷新内容列表。感谢markhunte向我指出了这一点!这是更新的脚本:
(*
Author: Anil Natha
Description:
This script toggles the visibility of hidden files in OS X. This includes
showing hidden files in Finder windows and on the desktop.
Last Updated: 2015-02-20
*)
tell application "System Events"
try
set hiddenFilesDisplayStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
set hiddenFilesDisplayStatus to "NO"
end try
set hiddenFilesNewDisplayStatus to "NO"
if hiddenFilesDisplayStatus is "NO" then
set hiddenFilesNewDisplayStatus to "YES"
end if
do shell script "defaults write com.apple.finder AppleShowAllFiles " & hiddenFilesNewDisplayStatus
end tell
tell application "Finder"
set allWindows to windows
repeat with currentWindow in allWindows
set currentWindowView to get the current view of the currentWindow
set alternateWindowView to list view
if currentWindowView is list view then
set alternateWindowView to icon view
end if
set the current view of the currentWindow to alternateWindowView
set the current view of the currentWindow to currentWindowView
end repeat
end tell
下面列出了较旧版本的脚本。尽管它可以工作,但是由于上面的脚本可以更有效地工作,所以我不建议您再使用它。
tell application "System Events"
set hiddenFilesDisplayStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles"
set hiddenFilesNewDisplayStatus to "NO"
if hiddenFilesDisplayStatus is "NO" then
set hiddenFilesNewDisplayStatus to "YES"
end if
do shell script "defaults write com.apple.finder AppleShowAllFiles " & hiddenFilesNewDisplayStatus
do shell script "killall Finder"
end tell