有没有一种方法可以将您的自定义键盘快捷键保存在配置文件中?


9

有没有一种方法可以将我的自定义键盘快捷键保存在配置文件中?

我想要这样做的原因是,这样我就可以将该配置文件放在云中(使用git,dropbox等),并在我拥有的每台OS X计算机上链接此文件,因此快捷方式始终是每台计算机上的保存。

Answers:


4

我使用这样的shell脚本:

defaults write -g NSUserKeyEquivalents '{
"Show in Finder"="$@r";
"Reveal"="$@r";
"Use Selection for Find"="@e";
"Find and Replace..."="~@f";
"Find Next"="@g";
"Find Previous"="$@g";
"Line Spacing..."="~@l";
"Zoom Reset"="@0";
"Original Size"="@0";
"Actual Size"="@0";
"Automatically Resize"="@9";
"Automatic Fit"="@9";
"Zoom to Fit"="@9";
"Enter Full Screen"="^@f";
"Exit Full Screen"="^@f";
"Enter Full Screen Mode"="^@f";
"Exit Full Screen Mode"="^@f";
"Toggle Full Screen"="^@f";
"Full Screen"="^@f";
"Fullscreen"="^@f";
"Normal Screen"="^@f";
"Remove Full Screen"="^@f";
"Select Previous Tab"="~@\UF702";
"Previous Tab"="~@\UF702";
"Show Previous Tab"="~@\UF702";
"Previous Workspace"="~@\UF702";
"Select Previous Tab View"="~@\UF702";
"Select Next Tab"="~@\UF703";
"Next Tab"="~@\UF703";
"Show Next Tab"="~@\UF703";
"Next Workspace"="~@\UF703";
"Select Next Tab View"="~@\UF703";
"Shift Left"="^\UF702";
"Decrease Indent Level"="^\UF702";
"Decrease Paragraph Indent"="^\UF702";
"Decrease Level"="^\UF702";
"Shift Right"="^\UF703";
"Increase Indent Level"="^\UF703";
"Increase Paragraph Indent"="^\UF703";
"Increase Level"="^\UF703";
"Shift Up"="^\UF700";
"Move Line Up"="^\UF700";
"Shift Down"="^\UF701";
"Move Line Down"="^\UF701";
"Minimize"="\U200B";
"Minimize All"="\U200B";
}'

defaults write com.apple.finder NSUserKeyEquivalents '{
"Show Package Contents"="@\r";
}'

defaults write -app iTerm NSUserKeyEquivalents '{
"Select Pane Above"="@\UF700";
"Select Pane Below"="@\UF701";
"Previous Pane"="@\UF702";
"Next Pane"="@\UF703";
"Open Autocomplete..."="@;";
}'

defaults write -app Safari NSUserKeyEquivalents '{
"Reopen Last Closed Window"="~@r";
"Reopen All Windows from Last Session"="~$@r";
"Mail Contents of This Page"="\U200B";
}'

defaults write -app Sequential NSUserKeyEquivalents '{
"Move to Trash"="\b";
}'

defaults write -app Skim NSUserKeyEquivalents '{
"Single Page Continuous"="$@0";
"Single Page"="$@1";
"Two Pages"="$@2";
"Crop"="@k";
}'

defaults write -app Transmit NSUserKeyEquivalents '{
"Show Invisible Files"="$@.";
"Hide Invisible Files"="$@.";
"Synchronize..."="$@y";
}'

defaults write -app WriteRoom NSUserKeyEquivalents '{
"Column 40"="$@1";
"Column 50"="$@2";
"Column 60"="$@3";
"Column 66"="$@4";
"Column 80"="$@5";
"Column 90"="$@6";
"Column 120"="$@7";
"Column 200"="$@8";
"Column Window Width"="$@0";
"Enter Full Screen Single"="^@f";
"Exit Full Screen Single"="^@f";
"Enter Full Screen"="$@f";
"Exit Full Screen"="$@f";
}'

快捷方式字符串使用与DefaultKeyBinding.dict中相同的格式,但是delete为\U0008\b),正向删除为\U007F

您可以通过将菜单项分配给\U200B(零宽度空间)之类的功能来禁用快捷方式。nil当您键入n某些应用程序(例如Audacity)时,系统会触发该操作。\0当您在10.9中按下Safari中的任意键时,将触发该事件。\1当您按下主屏幕键时会被触发。

defaults -app 不适用于Finder或Notes等某些应用程序。

defaults find NSUserKeyEquivalents 显示当前设置。


我有一个安装脚本defaults write -g NSUserKeyEquivalents '{ "Zoom"="@$m";}'-该组合有@$m什么作用?你能解释一下每个那些,@$,和m,和它们的用法?
咆哮者

2

应用程序快捷方式可以存储在两个位置:

  • 特定于应用的plist

    ~/Library/Preferences/com.apple.iTunes.plist
    
  • 全局首选项plist

    ~/Library/Preferences/.GlobalPreferences.plist
    

服务快捷方式存储在中~/Library/Preferences/pbs.plist


~/Library/Preferences/pbs.plist似乎不是MacOS Sierra上的位置。您知道塞拉利昂在哪里吗?
咆哮者
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.