Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I occasionally see howtos that allow you to change the functionality of some applications on OSX using defaults in the command line. I know that people find these configuration directives through scanning the application. How is that done?

fix: could have sworn it was option. My bad.

share|improve this question
1  
Do you mean defaults? –  Daniel Beck Sep 7 '11 at 19:02
    
Are you talking about graphical applications or UNIX applications? –  peelman Sep 7 '11 at 19:19
    
Graphical / .app –  kylehotchkiss Sep 7 '11 at 19:30

2 Answers 2

up vote 3 down vote accepted

You can use defaults to not only change these values, but also to list them.

defaults read -g show "global" options, while defaults read com.company.ProgramName show the defaults (i.e. configuration options) for a particular program. In this context, com.company.ProgramName is the bundle identifier of the program, e.g. com.apple.TextEdit or com.culturedcode.Things. More on this.


For example, run defaults read com.apple.Finder and you will find a line that says AppleShowAllFiles = FALSE or something similar. Now be adventurous and run defaults write com.apple.Finder AppleShowAllFiles -boolean TRUE and restart Finder to see what happens.

For more information how to use defaults, enter man defaults to view its documentation. It can become quite complex, and some things related to lists and dictionaries are pretty much impossible to do. Once you get that far, look up /usr/libexec/PlistBuddy -- there are some examples how to use it on this site, just use the search function.


Find out a particular program's bundle identifier:

To find out what your application uses for com.vendor.yourapp, right-click the application bundle, select Show Package Contents, navigate to Contents, open Info.plist using a text editor, or better a property list editor like Property List Editor or Xcode 4 (both part of Apple's developer tools) and look for CFBundleIdentifier or the like.


Another tool you can use is strings. It will display all strings (i.e. possibly useful sequences of characters) in a binary file. Note that this yields tons of false positives, since Objective-C function calls are also shown, as well as regular output that is shown on the UI.


Secrets also offers a database of hidden settings for OS X, sorted by application. These can be changed by using defaults. For your convenience, you can also download a Preference Pane from the website, which allows you to change these over your System Preferences.

share|improve this answer
    
Top notch answer Daniel. Thanks! –  kylehotchkiss Sep 7 '11 at 19:31
#!/bin/sh

# find key names in ~/Library/Preferences/`osascript -e 'id of app "iTunes"'`.plist
defaults read com.apple.iTunes | ruby -e 'puts STDIN.read.scan(/^    \"?([a-zA-Z_.\-]+?)\"? /)' > keys.txt

# extract identifiers from a binary
# (the output is tens of thousands of lines even after grepping)
strings - /Applications/iTunes.app/Contents/MacOS/iTunes | egrep "^[a-zA-Z][a-zA-Z_.\-]{7,}$" | ruby -e 'puts STDIN.read.split("\n").uniq' > strings.txt

# the identifiers for preferences often appear near each other
for x in `cat /0/keys.txt`; do
    grep -C 10 "$x" strings.txt
done | ruby -e 'puts STDIN.read.split("\n").uniq' > strings2.txt

Another method using the GNU debugger: arcticmac.home.comcast.net/~arcticmac/tutorials/gdbFindingPrefs.html

share|improve this answer
    
Like the expansiveness of this. Thanks! –  kylehotchkiss Sep 13 '11 at 18:38

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.