如何将所有键盘快捷键从一台Mac迁移到另一台?


11

我有很多自定义键盘快捷键,它们将是Mac的迁移。我测试了迁移助手,但似乎没有得到这些。

我在某处读到它们存储在该文件~/Library/Application Support夹中各个应用程序的plist文件中,但是即使在通过快捷方式复制了其中几个文件夹之后,这些文件似乎也没有出现。

如何将所有键盘快捷键迁移到新的Mac?

screenshot-with-shadow.png

Answers:


13

可以从应用程序快捷方式选项卡中更改快捷方式存储在~/Library/Preferences/.GlobalPreferences.plist和在应用程序的属性列表~/Library/Preferences/*.plist~/Library/Containers/*/Data/Library/Preferences/*.plist

$ defaults find NSUserKeyEquivalents
Found 1 keys in domain 'Apple Global Domain': {
    NSUserKeyEquivalents =     {
        "Actual Size" = "@0";
        "Automatic Fit" = "@9";
        "Automatically Resize" = "@9";
        "Browse All Versions..." = "^@v";
        "Decrease Indent Level" = "^\\Uf702";
        "Decrease Level" = "^\\Uf702";
        "Decrease Paragraph Indent" = "^\\Uf702";
        "Enter Full Screen" = "^@f";
        "Enter Full Screen Mode" = "^@f";
        "Exit Full Screen" = "^@f";
        "Exit Full Screen Mode" = "^@f";
        "Find Next" = "@g";
        "Find Previous" = "$@g";
        "Find and Replace..." = "~@f";
        "Full Screen" = "^@f";
        Fullscreen = "^@f";
        "Increase Indent Level" = "^\\Uf703";
        "Increase Level" = "^\\Uf703";
        "Increase Paragraph Indent" = "^\\Uf703";
        "Line Spacing..." = "~@l";
        Minimize = "\001";
        "Minimize All" = "\001";
        "Move Line Down" = "^\\Uf701";
        "Move Line Up" = "^\\Uf700";
        "Next Tab" = "~@\\Uf703";
        "Next Workspace" = "~@\\Uf703";
        "Normal Screen" = "^@f";
        "Original Size" = "@0";
        "Previous Tab" = "~@\\Uf702";
        "Previous Workspace" = "~@\\Uf702";
        "Remove Full Screen" = "^@f";
        Reveal = "$@r";
        "Select Next Tab" = "~@\\Uf703";
        "Select Next Tab View" = "~@\\Uf703";
        "Select Previous Tab" = "~@\\Uf702";
        "Select Previous Tab View" = "~@\\Uf702";
        "Shift Down" = "^\\Uf701";
        "Shift Left" = "^\\Uf702";
        "Shift Right" = "^\\Uf703";
        "Shift Up" = "^\\Uf700";
        "Show Next Tab" = "~@\\Uf703";
        "Show Previous Tab" = "~@\\Uf702";
        "Show in Finder" = "$@r";
        "Toggle Full Screen" = "^@f";
        "Use Selection for Find" = "@e";
        "Zoom Reset" = "@0";
        "Zoom to Fit" = "@9";
    };
}
Found 1 keys in domain 'com.panic.Transmit': {
    NSUserKeyEquivalents =     {
        "Hide Invisible Files" = "$@.";
        Refresh = "@r";
        "Show Invisible Files" = "$@.";
        "Synchronize..." = "$@y";
    };
}
Found 1 keys in domain 'net.sourceforge.skim-app.skim': {
    NSUserKeyEquivalents =     {
        Crop = "@k";
        "Single Page" = "$@1";
        "Single Page Continuous" = "$@0";
        "Two Pages" = "$@2";
    };
}
Found 1 keys in domain 'com.googlecode.iterm2': {
    NSUserKeyEquivalents =     {
        "Next Pane" = "@\\Uf703";
        "Open Autocomplete..." = "@;";
        "Previous Pane" = "@\\Uf702";
        "Select Pane Above" = "@\\Uf700";
        "Select Pane Below" = "@\\Uf701";
    };
}
Found 1 keys in domain 'net.notational.velocity': {
    NSUserKeyEquivalents =     {
        Bold = "\001";
        Delete = "$@d";
        Italic = "\001";
        "Plain Text Style" = "\001";
        Strikethrough = "\001";
    };
}
Found 1 keys in domain 'com.apple.Safari': {
    NSUserKeyEquivalents =     {
        "Mail Contents of This Page" = "\001";
        "Reopen All Windows from Last Session" = "~$@r";
        "Reopen Last Closed Window" = "~@r";
    };
}
Found 1 keys in domain 'com.hogbaysoftware.WriteRoom.mac': {
    NSUserKeyEquivalents =     {
        "Column 120" = "$@7";
        "Column 200" = "$@8";
        "Column 40" = "$@1";
        "Column 50" = "$@2";
        "Column 60" = "$@3";
        "Column 66" = "$@4";
        "Column 80" = "$@5";
        "Column 90" = "$@6";
        "Column Window Width" = "$@0";
        "Enter Full Screen" = "$@f";
        "Enter Full Screen Single" = "^@f";
        "Exit Full Screen" = "$@f";
        "Exit Full Screen Single" = "^@f";
    };
}

我实际上使用像这样的shell脚本来配置快捷方式:

defaults write -g NSUserKeyEquivalents '{
"Browse All Versions..." = "^@v";
"Minimize" = "\1";
"Minimize All" = "\1";
"Show Previous Tab" = "~@\Uf702";
"Show Next Tab" = "~@\Uf703";
}'

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

快捷方式字符串使用与DefaultKeyBinding.dict中相同的格式。您可以通过将菜单项分配给来删除快捷方式\1。如果将菜单项分配给nil,则在诸如Audacity之类的某些应用程序中按n时将触发该菜单项。如果您将菜单项分配给\0,则在10.9中按Safari中的任何键都会触发该菜单项。

请注意,首选项存储在Mavericks中。退出并重新打开应用程序后,仍将应用使用默认设置所做的更改。但是,如果您直接编辑plist或替换plist,则还必须运行killall cfprefsddefaults read /path/to/plist


9

感谢现有的答案,我建立了一个脚本,它将快捷方式保存到一个脚本中,以便在其他计算机上运行。

#!/bin/sh
# save-hotkeys.sh

DESTFILE=~/install-hotkeys.sh
echo '#!/bin/bash' > $DESTFILE

defaults find NSUserKeyEquivalents | sed -e "s/Found [0-9]* keys in domain '\\([^']*\\)':/defaults write \\1 NSUserKeyEquivalents '/" -e "s/    NSUserKeyEquivalents =     {//"  -e "s/};//" -e "s/}/}'/" >> $DESTFILE
echo killall cfprefsd >> $DESTFILE
chmod a+x $DESTFILE

将其保存到一个名为的文件中save-hotkeys.sh,然后通过运行来执行它sh save-hotkeys.sh。在远程计算机上,./install-hotkeys.sh在与文件相同的目录中执行。在我的示例中,我将文件保存到保管箱,以便将其同步到其他计算机。


嗨,艾伦,太好了。如何运行该脚本?将其保存到文件中?应该是什么扩展名?通过双击运行文件?
愤怒的猕猴桃

添加了一些有关如何使用它的解释。
艾伦·舒特科

@ Alan Shutko,我在执行save-hotkeys:Af-MacBook-Pro:HD 2 af $ sh save-hotkeys.sh save-hotkeys.sh时遇到此错误:第5行:/ Users / Af / Dropbox / install -hotkeys.sh:没有这样的文件或目录
愤怒的猕猴桃

嗨,艾伦,有更新吗?
愤怒的猕猴桃

1
我在10.15.2卡塔利娜不起作用,执行该文件后,它会报告: Unexpected argument NSUserKeyEquivalents; leaving defaults unchanged.
米哈伊Šašić
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.