Skip to content

Instantly share code, notes, and snippets.

@dlo
Last active March 15, 2017 04:06
Show Gist options
  • Save dlo/d130512f192b86306176 to your computer and use it in GitHub Desktop.
Save dlo/d130512f192b86306176 to your computer and use it in GitHub Desktop.
Applescript / Keyboard Maestro Macro to switch to last tab in Safari.
tell application "Safari"
set tabCount to number of tabs in front window
end tell
tell front window of application "Safari"
set current tab to tab tabCount
end tell
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>CreationDate</key>
<real>469386566.37803501</real>
<key>FocussedWindowConditionType</key>
<string>Exists</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
<array>
<dict>
<key>Actions</key>
<array>
<dict>
<key>DisplayKind</key>
<string>None</string>
<key>IncludeStdErr</key>
<true/>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteAppleScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>tell application "Safari"
set tabCount to number of tabs in front window
end tell
tell front window of application "Safari"
set current tab to tab tabCount
end tell</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
</dict>
</array>
<key>CreationDate</key>
<real>0.0</real>
<key>IsActive</key>
<true/>
<key>ModificationDate</key>
<real>469386895.74191302</real>
<key>Name</key>
<string>Switch to Last Tab</string>
<key>Triggers</key>
<array>
<dict>
<key>FireType</key>
<string>Pressed</string>
<key>KeyCode</key>
<integer>25</integer>
<key>MacroTriggerType</key>
<string>HotKey</string>
<key>Modifiers</key>
<integer>256</integer>
</dict>
</array>
<key>UID</key>
<string>932A436B-3B57-4155-9057-6E32E29A46FC</string>
</dict>
</array>
<key>Name</key>
<string>Safari Macros</string>
<key>Targeting</key>
<dict>
<key>Targeting</key>
<string>Included</string>
<key>TargetingApps</key>
<array>
<dict>
<key>BundleIdentifier</key>
<string>com.apple.Safari</string>
<key>Name</key>
<string>Safari</string>
<key>NewFile</key>
<string>/Applications/Safari.app</string>
</dict>
</array>
</dict>
<key>ToggleMacroUID</key>
<string>B632E007-0F39-4112-A403-6EFDD3E0264D</string>
<key>UID</key>
<string>37249F4C-C592-473B-B492-9DACFDD20972</string>
</dict>
</array>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment