Skip to content

Instantly share code, notes, and snippets.

@cspickert
Created April 26, 2012 16:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cspickert/2500847 to your computer and use it in GitHub Desktop.
Save cspickert/2500847 to your computer and use it in GitHub Desktop.
Jump to the documentation search field in Xcode 4 using AppleScript.
#!/usr/bin/osascript
-- Jump to the documentation search field in Xcode 4's Organizer
-- To use, make sure "Enable access for assistive devices" is enabled in the Universal Access pref pane
tell application "System Events"
tell process "Xcode"
-- Activate Xcode if necessary
set frontmost to true
-- Open the Organizer
keystroke "2" using {shift down, command down}
set organizer to window 1
-- Select the Documentation panel if it's not already selected
if the title of organizer is not "Organizer - Documentation" then
click button "Documentation" of tool bar 1 of organizer
delay 0.1
set organizer to window 1
end if
-- Move focus to the search field
set searchField to text field 1 of splitter group 1 of organizer
set searchField's focused to true
end tell
end tell
@cspickert
Copy link
Author

To execute this script using a keyboard shortcut:

  1. Make sure the script is executable: chmod +x "Search Xcode Documentation.applescript"
  2. Go to the Behaviors tab in Xcode's Preferences
  3. Add a new behavior and click on the faint keyboard shortcut indicator on the right-hand side of its name in the sidebar to add a shortcut (or use the Key Bindings tab)
  4. Scroll down to the "Run" checkbox, check it, and use the pull-down menu to select the script file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment