Bagaimana saya bisa memigrasi semua pintasan keyboard dari satu mac ke mac lainnya?

11

Saya memiliki banyak pintasan keyboard khusus dan akan menjadi migrasi Mac. Saya menguji Asisten Migrasi dan sepertinya tidak mendapatkannya.

Saya membaca di suatu tempat bahwa mereka disimpan dalam file plist masing-masing aplikasi di ~/Library/Application Supportfolder tetapi bahkan setelah menyalin beberapa folder ini melalui cara pintas tampaknya tidak mengikuti.

Bagaimana saya bisa mendapatkan semua pintasan keyboard dimigrasikan ke mac baru?

tangkapan layar-dengan-shadow.png

cwd
sumber

Jawaban:

13

Pintasan yang dapat diubah dari tab Pintasan Aplikasi disimpan di ~/Library/Preferences/.GlobalPreferences.plistdan dalam daftar properti aplikasi di ~/Library/Preferences/*.plistdan ~/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";
    };
}

Saya sebenarnya menggunakan skrip shell seperti ini untuk mengkonfigurasi pintasan:

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";
}'

String pintasan menggunakan format yang sama seperti di DefaultKeyBinding.dict . Anda dapat menghapus pintasan dengan menetapkan item menu ke \1. Jika Anda menetapkan item menu ke nil, itu dipicu ketika Anda menekan n di beberapa aplikasi seperti Audacity. Jika Anda menetapkan item menu ke \0, itu dipicu ketika Anda menekan tombol apa saja di Safari di 10.9.

Perhatikan bahwa preferensi di-cache di Mavericks. Perubahan yang dilakukan dengan default masih diterapkan setelah Anda baru saja keluar dan membuka kembali aplikasi. Tetapi jika Anda mengedit plist secara langsung atau mengganti plist, Anda juga harus menjalankan killall cfprefsdatau defaults read /path/to/plist.

Lri
sumber
9

Berkat jawaban yang ada, saya membuat skrip yang akan menyimpan pintasan ke skrip untuk dijalankan di komputer lain.

#!/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

Simpan ini ke file yang dipanggil save-hotkeys.shdan jalankan dengan menjalankan sh save-hotkeys.sh. Di mesin jarak jauh, jalankan ./install-hotkeys.shsementara di direktori yang sama dengan file. Dalam contoh saya, saya menyimpan file ke dropbox sehingga disinkronkan ke komputer saya yang lain.

Alan Shutko
sumber
Hai Alan, bagus sekali. Bagaimana menjalankan skrip itu? Simpan ke dalam file? Ekstensi apa yang seharusnya? Jalankan dengan klik dua kali file tersebut?
Kiwi
Menambahkan beberapa penjelasan cara menggunakannya.
Alan Shutko
@ Alan Shutko, saya mendapatkan kesalahan ini ketika saya menjalankan save-hotkeys: Af-MacBook-Pro: HD 2 af $ sh save-hotkeys.sh save-hotkeys.sh: baris 5: / Users / Af / Dropbox / install -hotkeys.sh: Tidak ada file atau direktori seperti itu
angry kiwi
Hai Alan, kabar terbaru?
angry kiwi
1
Tidak berfungsi untuk saya pada 10.15.2 Catalina, setelah mengeksekusi file, ia melaporkan: Unexpected argument NSUserKeyEquivalents; leaving defaults unchanged.
Siniša Šašić