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

  • I know this is completely unhelpful, but I can believe they would do that. :P Especially given how...rough some of the edges of Yosemite are in general. – tubedogg Nov 7 '14 at 22:10
  • Anything new on that? It's been a few month and this problem still seems to persist :( – dvcrn Apr 27 '15 at 5:53
  • This "Show all tabs" view with searching is now available to all apps that use native tabs in High Sierra. – Steve Moser Dec 18 '17 at 14:06
up vote 3 down vote accepted

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
  • I'll mark this as "best answer" for now, since it's a pretty thorough treatment on the subject, and shows that it's pretty much impossible. Thank you. – SamBeran Dec 4 '14 at 16:18
  • A bit clunky workaround is to use Shortcat to select the tab. – Adam Lindberg Aug 7 at 7:34

I think I got your answer. I spent all day looking for this. I use a great free app called BetterTouchTool( using OS X 10.10 ) to add aditional gestures and shortcuts to all apple devices, and it work instantaneously! No delay!

I will make screenshots with each step you need to configure. NOTE: It will bind the mouse position as a keyboard shortcut of your choice when you're using safari. Downsides: You can't change safari's window position, and the position of the mouse will be different from the monitor from your notebook. Solution: I recommend map the mouse position using it in fullscreen with the screen you most use most of the times( or just map two shortcuts for each screen )

  • 1 Download the app http://www.bettertouchtool.net

  • 2 Open the app, select keyboard, add an app to list to the shortcuts you will add( in this case Safari ), choose your shortcut( I'm mapping "Option + 1" in this screenshot ), then, inside the Trigger select menu, select "Move Mouse to Position" in the "Other Mouser Actions".I marked the wrong option in the screenshot, it's the option above. It's NOT "Save mouse position". Sorry i'm too tired, it's 3 am and I have to work tomorrow enter image description here

  • 3 Choose where you want the cursor to go( The position in the input box will check the first result when the UI is showing ~3 results)

enter image description here

  • 4 Add a following event: A left click event. And that's it! enter image description here

Do the same with a different mouse position to get the 2nd, 3rd.. result but keep in mind the ui will change if larger results, sometimes even hiding the first result.

  • I have remapped shift+command+\ to command+d. So then you just do command+d command+f text here command+d. – Dzh Apr 6 '16 at 8:32

I've been using Applescript to do this since before they added this feature:

http://hea-www.harvard.edu/~fine/OSX/safari-tabs.html

It pops up a search dialog, you enter your search, and it immediately activates a single matching tab, or gives you a dialog to select from a list of matching tabs. It brings the window to front and makes this the active tab in the window.

(I have a similar script for finding Terminal windows.)

  • Very cool; I think I'll try this. If I understand it, it looks like your script also searches all open windows, instead of just the current one. Is that correct? This is a feature I would like that the normal search doesn't have. – krs013 Nov 6 '15 at 18:41

I am a bit late to the party, but I think Shortcat will perform the necessary functionality.

With the added bonus such that it can be used with Mail, etc.

Use Automator and paste the AppleScript attaching it to a keyboard shortcut like described in:

How do I assign a keyboard shortcut to an AppleScript I wrote?

set question to display dialog ("Find Safari tab:") default answer ""
set searchpat to text returned of question

tell application "Safari"
    set winlist to every window
    set winmatchlist to {}
    set tabmatchlist to {}
    set tabnamematchlist to {}
    repeat with win in winlist
        set ok to true
        try
            set tablist to every tab of win
        on error errmsg
            --display dialog name of win as string
            set ok to false
        end try
        if ok then
            repeat with t in tablist
                if searchpat is in (name of t as string) then
                    set end of winmatchlist to win
                    set end of tabmatchlist to t
                    set end of tabnamematchlist to (id of win as string) & "." & (index of t as string) & ".  " & (name of t as string)
                    --display dialog name of t as string
                else if searchpat is in (URL of t as string) then
                    set end of winmatchlist to win
                    set end of tabmatchlist to t
                    set end of tabnamematchlist to (id of win as string) & "." & (index of t as string) & ".  " & (name of t as string)
                    --display dialog name of t as string
                end if
            end repeat
        end if
    end repeat
    if (count of tabmatchlist) = 1 then
        --display dialog "one!"
        set w to item 1 of winmatchlist
        set t to item 1 of tabmatchlist
        set current tab of w to t
        set index of w to 1
    else if (count of tabmatchlist) = 0 then
        display dialog "No matches"
    else
        set whichtab to choose from list of tabnamematchlist with prompt "The following tabs match, please select one:"
        set AppleScript's text item delimiters to "."
        if whichtab is not equal to false then
            set tmp to text items of (whichtab as string)
            set w to (item 1 of tmp) as integer
            set t to (item 2 of tmp) as integer
            set current tab of window id w to tab t of window id w
            set index of window id w to 1
        end if
    end if
end tell

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.