I'm trying to open Preference Pane from command. However, when I invoke open /System/Library/PreferencePanes/Dock.prefPane
as in
How do you access network preferences from the Terminal?, I get Finder that contains the preference pane opened instead.
What might be a way to open the preference pane? I also tried /System/Library/PreferencePanes/Dock.prefPane/Contents/MacOS/Dock
to invoke the binary to have this error message.
-bash: /System/Library/PreferencePanes/Dock.prefPane/Contents/MacOS/Dock: cannot execute binary file
Best Answer
You can open System Preferences using its URL scheme:
You can jump to a specific anchor on a specific pane using:
You can get the list of panes and anchors using AppleScript:
Update: Apple has restricted use of the URL scheme in 10.11. As of this release only preference panes with NSPrefPaneAllowsXAppleSystemPreferencesURLScheme set in their Info.plist can be opened via the URL scheme.
Source: @Matt Stevens answer