MacOS – Safari “Search Tabs” Keyboard Shortcuts

macossafaritabs

The new "Search Tabs" feature of Safari 8 is pretty nice. When "show all tabs" is activated, you can type some text to filter the tabs to the one you want. However, once I have a single tab visible, it would be very nice to be able to activate that tab. This would allow "spotlight" type functionality for tabs.

However, it doesn't seem like there is a keyboard shortcut to activate the tab once I've searched for it, so I'm forced to click the tab with my mouse! This seems like an oversight, I can't believe Apple would add a nice way to filter the tabs, but no way to select one!

Screenshot:

enter image description here

Best Answer

I have tried the following key combinations in an attempt to do this, to no effect:

  • Command+Return ...+Space
  • Option+Return ...+Space
  • Control+Return ...+Space
  • Command+Shift+\ (The "Show All Tabs" Command on my Macbook)

This leads me to believe that it really is an oversight on Apple's part.

Kludge: Create An Automator Command to Simulate A Mouse Click

I used code that I found at https://discussions.apple.com/thread/3708948 to put together the following AppleScripts:

Attempt 1: Didn't Work I ran this code in an Applescript wrapped in an Automator Service mapped to "Command+Shift+Option+Control+Space", using the numbers I get from pressing "Command+Control+Shift+4" to get the address for the area (600 pixels horizontal from left, 300 pixels vertical from top), and it would work in normal Safari (pressing the key combination would make the mouse click at that pixel address), but it had no effect when the same key command was run in the "Show All Tabs" mode in Safari!

on run {input, parameters}
    tell application "System Events"
            tell process "Safari"
                click at {600, 300}
            end tell
        end tell

        return input
    end run

Attempt #2: Worked, but Not Feasible

I did get a key command working with the following Applescript wrapped in an Automator Service, but it took 5.125 seconds to complete:(

    on run {input, parameters}

    set x to 600
    set y to 150

    do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
          theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
          CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
          mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
          mouseEvent(kCGEventLeftMouseDown, posx,posy);
          mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent);             # Save current mouse position
mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y));      # Restore mouse position
END"
    return input
end run