Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am currently creating a list of terminal commands to set up a new mac system according to my needs. Now I would like to add new keystrokes to Preview (normally in the system settings => keyboard) from the Terminal. This is probably possible using the defaults write command but so far, I haven't found the concrete plist or path I would have to change.

Has anybody already tried this or knows a good resource for such settings?

share|improve this question
    
Found the answer on StackOverflow: stackoverflow.com/questions/7219134/… –  str Nov 30 '12 at 22:13
add comment

2 Answers

up vote 1 down vote accepted

You can add an NSUserKeyEquivalents dictionary to ~/Library/Containers/com.apple.Preview/Data/Library/Preferences/com.apple.Preview.plist.

defaults write -app preview NSUserKeyEquivalents '{
"Single Page" = "@1";
"Two Pages" = "@2";
"Continuous Scroll" = "@3";
"Adjust Size..." = "~@i";
"Adjust Color..." = "@u";
}'

The shortcuts for all applications are in ~/Library/Preferences/.GlobalPreferences.plist.

defaults write -g NSUserKeyEquivalents '{
"Show in Finder" = "$@r";
"Reveal" = "$@r";
"Delete Row" = "~@\b";
"Delete Rows" = "~@\b";
"Delete Column" = "$@\b";
"Delete Columns" = "$@\b";
"Minimize" = "\0";
"Minimize All" = "\0";
}'

The shortcut format is described in the Cocoa Text System article. The -app option doesn't work with some applications like Finder or Notes. If a menu item was assigned to nil, pressing L would trigger it in Audacity.

share|improve this answer
    
Yes that is exactly what they propose in the link from the comment section. I will mark this as answer anyway, thanks. –  str Dec 1 '12 at 16:02
add comment

You're better off using the Keyboard Shortcuts tab of the Keyboard pane in System Preferences. Click on Application Shortcuts, click the + button, and choose Preview; for example, I use option-command-S to "Adjust Size..." and option-command-0 to "Zoom to Fit."

As with all custom keyboard shortcuts, you must enter the menu item exactly, including ellipsis, for the new shortcut to work.

share|improve this answer
    
I know how it works in the system preferences, but that is not how I would like to do it. I prefer a script I can just run on different machines instead of fiddling around on every machine. –  str Nov 30 '12 at 19:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.