Counting Chrome Tabs on MacOS (Or, I have an open tabs problem!)

Another aide-mémoire; open Chrome tabs can, on MacOS, be counted via the following incantation. This particular incantation will pull the tab count from all open windows – minimised or otherwise – without the need to activate Chrome in any way.

osascript -e{'set text item delimiters to linefeed','tell app"google chrome"to url of tabs of windows as text'} | wc -l

Which, when run on my currently open set of tabs, comes back with a number slightly higher than 4,000.

A little grep magic can also be mixed in, allowing you to count how many tabs you have open from a particular domain name.

osascript -e{'set text item delimiters to linefeed','tell app"google chrome"to url of tabs of windows as text'} | grep "www.youtube.com" |  wc -l

And, for my sins, that tells me I have a little more than 1700 Youtube tabs open.

I may have a problem…

Leave a Reply

Your email address will not be published. Required fields are marked *