Search Titles of Safari or Chrome Tabs in Multiple Windows and Bring Match to Front

Crud, I missed that.

Someone should take it over. It's by far the best session-manager available for Safari.


Hey Mitchell,

If you look at the post I linked to that has my _Safari » Switch Tabs-Windows Using Pick-List macro – and actually try out the macro – you'll see it marks the front tab of each window.


Hey Mitchell,

The first page has a Popular, Recent and Categories links.

So you can search or browse.


Expanding upon my scriptlet above and excerpted from the referenced macro (with a slight embellishment):

tell application "Safari"
   tell (every window where its document is not missing value)
      set docCount to count
      set currentTabIndex to index of current tab
      set tabCount to count of tabs
      set tabNames to name of tabs
      set tabURLs to URL of tabs
   end tell
end tell


Mostly just a haphazard impatient working style (as you probably could have guessed from all my too-hasty and misinformed posts :-).

But there are some underlying factors:

  • I work with a lot of different technologies and applications and often have multiple pages of documentation open for many of them at any given time
  • Working with all these technologies leads to a proliferation of searches for how to do things or resolve problems — I bet I have at least 20-30 stackoverflow tabs open at any given time
  • It often isn't enough to read answers to my questions or searches, I keep them around until I've read them and tried what they say enough to be done with them
  • Often I hit a topic in a search and open 5-10 results from the results page into tabs of the same window, and I don't read them (all) right away
  • To some extent I am using windows and tabs as a structured version of Safari's reading list, which I've never found a use for.
  • I also have very many bookmark folders, and subfolders, etc. and I often bookmark the kinds of pages I mentioned above, but there's no good way to filter out bookmarks according to whether I've read their pages, and in any case I might not have finished with them when I bookmarked them.
  • I use Evernote a little but find it too cumbersome to deal with this flood of bookmarked pages.
  • Here's an example: I encounter so much good stuff on the KM forum that often all I do is just click the topic that looks interesting and move on. Send up with typically 5 or so windows each with typically 5 or so tabs all open to KM forum pages

At the moment my Safari Windows and tabs are quite a bit more cleaned up than usual. In the hope I won't embarrass myself by anything included there, I put in my Dropbox the HML file generated for my current Safari state.

One of the things I often do to cut back on the documentation-related tabs is use Firefox for, and only for, technology documentation (unless I am developing or debugging something for which Firefox tools are helpful). I used to use OmniWeb for that, loving its workspace and vertical tab feature and highly Mac-Style interface (Omnigroup originating as a provider of applications for NeXT). I was very happy recently to discover a tree-structured vertical tab extension for Firefox (and many other vertical tab and tab-grouping extensions listed on that page).

Ill probably think of more to say about this, but I doubt there would be any point.

Working style, is the key, I think. In fact, the link cited above for the Firefox tree-tab extension says at one point "If you often use many many tabs…", so I know there is at least one person out there who shares this style :-).

Yeah, thats good. There are so many tab-managing macros floating around the KM forum that I haven’t kept up with all of them, no less read their implementations carefully. Best way to learn better ways to do things is to discover them in other people’s code, of course.

No, it's a matter of a change in Apple's extensions policy that the author objected to. I don't know where that might be on the extension's web page, but I read it in a popup that showed up when I first installed the extension.

I found the problem. It was hidden because it was the result of accidentally using a feature of Safari I never used — pinned tabs. I don’t even know how they work. I can’t imagine why a pinned tab would show up as one of the tabs of every window.

Because pinned tabs are added to every window.

Perfectly insane if you ask me...


How'd you like to be able to create bookmarks in the Finder and auto-categorize and tag them?


Well, if it works for you, I guess that's all that matters. :slight_smile:

Personally, I can't imagine finding and navigating 250 open browser tabs.
It suggests that you are trying to work on multiple projects at the same time, literally. That wouldn't work for me -- too much noise and distractions.

I use the following to mainain order and still find things very quickly:

  • IQTell for project/task management
  • Evernote to use as my personal information database
    • All web pages of interest are clipped to EN and tagged for easy categorization and quick retrieval.
    • As I read the web article, I highlight text of interest, either during the clipping process, or later when I read it in Evernote
    • Evernote also makes it easy to attach/view files like PDF, All MS Office files, etc
    • Mac Spotlight also searches your Evernote Notes.
  • I clip all code into my snippet manager, Quiver.
  • I have about 10 folders in my Chrome Bookmark Bar, where I organize and keep all of my commonly used URLs. If I need to, I can easily search the Chrome bookmark page.

I have very, very, rarely need to have more than about 10 browser tabs open at once. Most new tabs come from a google search page, and I open each link in new tab. If the page isn't what i want, I close it. The link is still available on the search page. If I think I might need a page for future ref, then I clip it to Evernote.

One final note, if you use Chrome, you might find OneTab extension for Google Chrome helpful. They claim to "save up to 95% memory and reduce tab clutter".

Good luck.

Thanks — lots of good ideas there to think about. Yours is the most sophisticated use of Evernote I’ve heard of. I know I am not using more than its minimum features, but have yet to discipline myself enough to establish a workflow. I might try copying what you outlined.

The major thing that none of the organization techniques can handle is keeping a bunch of related documentation pages open – like the 10 or 15 pages I use most often when writing Python code. That’s where I am turning more and more to Firefox, leaving Safari for more normal use.

I tend to stay away from Chrome — don’t like some of its interface and especially don’t like its proliferation of processes using who knows how much memory and CPU (not that I’m really short in either of those). But when I do use Chrome it’s for yet another different kind of browsing.

Omniweb had this great feature: workspaces. They were snapshots of Window & Tab arrangements, with easy flipping among them. So I can arrange all my Python windows and tabs just how I want them, snapshot that, and switch to something else. Whenever I want Python documentation, I could just switch back to the Python workspace. Had workspaces for digital photography, Python, web technologies, Java, OS X, etc. Do you know of anything like this for any of the browsers? I suppose if I were clever i could figure out a way to use Sessions, or something like it, not just to capture the current browsing state, but a browsing state that I could flip back to. Probably can name sessions, but haven’t tried yet.

Great macro, thank you.
Would it be possible for me to ‘pre-fill’ the desired tab name? Instead of using the pick list?
I’m always checking to see if that tab exists and if so, go there, if not make a new one.


?? I'm on Safari - where is this "• Other •"

Sorry, confused, thought you were talking about a different macro:
Reveal Safari Windows

1 Like

This script "Find and activate specific tab (Chrome and:or Safari)" used to work for me using Chrome, but it quit working months ago. Was there an u Mac OS update or Chrome update that broke it? Currently, it mostly locks up Chrome for a minute, then a notification pop ups with: "JavaScript For Automation Results" then exits the script yielding no results. Is there an update to the script to get it working again?

Thanks – it does sound as if there has been a change in Chrome (which I haven't been using much for a while) I'll take a look over the weekend.

Not sure of your exact use case, but I've sketched something here (just for Chrome) which:

  • seems to find and activate the first tab which includes a given string.
  • was tested this evening with Chrome 86.0.4240.183

Activate a Chrome tab containing a given string.kmmacros (22.0 KB)

JS Source
(() => {
    'use strict';

    // Activate first Chrome tab with a title
    // which includes the given string.

    // Rob Trew @2020

    // main :: IO ()
    const main = () => {
            s = toLower(
                    'Keyboard Maestro Engine'
            ws = Application('Google Chrome').windows;
        return either(
            // Explanatory message,
            x => x
            // or title and url of activated tab.
            x => x
                0 < ws.length ? (
                ) : Left('No windows open in Chrome')
            )(frontWindow => {
                    tabIndex = frontWindow.tabs()
                        x => toLower(x.title()).includes(s)
                return bindLR(
                    -1 !== tabIndex ? (
                    ) : Left('No match found in tabs.')
                )(index => {
                    const tab = (
                        frontWindow.activeTabIndex = (1 + index),
                    return Right(

    // --------------------- GENERIC ---------------------

    // Left :: a -> Either a b
    const Left = x => ({
        type: 'Either',
        Left: x

    // Right :: b -> Either a b
    const Right = x => ({
        type: 'Either',
        Right: x

    // bindLR (>>=) :: Either a -> 
    // (a -> Either b) -> Either b
    const bindLR = m =>
        mf => undefined !== m.Left ? (
        ) : mf(m.Right);

    // either :: (a -> c) -> (b -> c) -> Either a b -> c
    const either = fl =>
        // Application of the function fl to the
        // contents of any Left value in e, or
        // the application of fr to its Right value.
        fr => e => 'Either' === e.type ? (
            undefined !== e.Left ? (
            ) : fr(e.Right)
        ) : undefined;

    // toLower :: String -> String
    const toLower = s =>
        // Lower-case version of string.

    // MAIN ---
    return main();
1 Like