我一直在努力弄清楚这一点。我有一个非常典型的Mac OS设置脚本:
https://gist.github.com/ryanpcmcquen/b2e608311f286a4ab3e1
我想将任务控制快捷键全部更改为Ctrl+ Alt+ ...而不是Ctrl+ ...。例如,默认值为:Ctrl+ Up以激活任务控制。我想将其更改为Ctrl+ Alt+ Up,因为当前的快捷方式与我使用的其他程序冲突。
请注意,我已经知道如何通过来完成此操作System Preferences > Keyboard > Shortcuts
,我正在寻找可编写脚本的命令行解决方案。
编辑:感谢@ user3439894,我经历了一个脚本,将所有plist键更改为我想要的键。唯一的问题是,它不起作用。:-(
这是我到目前为止的内容:
#!/bin/bash
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 32 "{enabled = 1; value = { parameters = (65535, 126, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 33 "{enabled = 1; value = { parameters = (65535, 125, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 34 "{enabled = 1; value = { parameters = (65535, 126, 3014656); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 35 "{enabled = 1; value = { parameters = (65535, 125, 3014656); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 79 "{enabled = 1; value = { parameters = (65535, 123, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 80 "{enabled = 1; value = { parameters = (65535, 123, 3014656); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 81 "{enabled = 1; value = { parameters = (65535, 124, 2883584); type = standard; }; }"
defaults write ~/Library/Preferences/com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 82 "{enabled = 1; value = { parameters = (65535, 124, 3014656); type = standard; }; }"
chown -Rf `whoami` ~/Library/Preferences/com.apple.symbolichotkeys.plist;
defaults read com.apple.symbolichotkeys
type = standard;
实际上应type = 'standard';
注意周围的引号'standard'
。即便如此,有时即使使用正确格式的命令行,更改也不会生效,即使; killall -u $USER cfprefsd
添加到defaults
命令末尾也是如此。同样,.plist
在这种用例中,文件的完整路径不是必需的,例如defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys ...
,命令的其余部分就足够了。