1

Running MacOS Monterey and Firefox 122.0. How can I close all tabs at once?

I found on the net the suggestion to use "command" + w, but this closes only the current tab (which I could also achieve by pressing "control" + w.

The best solution I found so far is "shift" + "command" + w (which closes the current Window), followed by "command" + n (which opens a new window without open tabs).

  • What is the difference between closing all tabs and closing the window? If the last tab is gone, there isn’t anything left to show. – nohillside Feb 06 '24 at 09:08
  • After closing the tabs, I have a window where I can start a new browsing session. Say I have the computer running for a few days, and 20 or 30 open tabs accumulated. I find that this looks confusing. I would like instead start new work in a single open tab. If I close the window, I have to open a new window to do this. This is the approach I'm doing now (two key combinations). I wonder whether there is a way to have this with only one key combination. According to Google, this is supposed to be possible, but as explained, this suggested key combination does not work for me. – user1934428 Feb 06 '24 at 09:20
  • What about an Apple script called by say cmnd+alt+W which does shift+cmnd+W then cmnd+n – Solar Mike Feb 06 '24 at 09:24
  • @SolarMike : This would be a possibility, though I thought that perhaps Firefox already would provide such a feature. Is it possible to associate such a script with Firefox, i.e. that the hotkey for this script works ONLY when Firefox has the focus, and not with any other program? Otherwise if I accidentally press this cmd-alt-w in a different program, it would possibly cause there something unwanted. – user1934428 Feb 06 '24 at 09:29
  • So have an if statement to make sure Firefox is the active program if not don't do the commands... – Solar Mike Feb 06 '24 at 09:31
  • And a quick search gives this, which you can edit to do what you want: https://superuser.com/q/526624 – Solar Mike Feb 06 '24 at 09:34
  • @SolarMike : I see that I need to get familiar with Applescript, but I feel that I am opening a can of worms here. From a design viewpoint, having a global hotkey associating with a master script and then asking in the script, what application it is in, is a maintenance nightmare. If I want to do this "hot key" different things in different applications, and by default just pass it on to the application, is counter intuitive. A more logical design would somehow associate a separate script program to the individual applications. But thanks anyway, I will think of it. – user1934428 Feb 06 '24 at 09:36
  • 1
    So your complaint is now you want it to work in different applications while in your first comment you complained that you only wanted it to work in Firefox. Some people can never be satisfied... – Solar Mike Feb 06 '24 at 09:37
  • @SolarMike : It's not a complain. It's a programmer's viewpoint: I work of course every day with various applications - say some browsers, some text editors, and a bunch of terminal apps. If the application is tabbed, I want to have a quick way to close all tabs, or maybe all tabs except the one which has the focus. Many applications open this feature. Firefox does not. The problem is not just the script, which you kindly pointed out to me; it is the association with a global hot key. If I can't do this, I need to put the logic inside the script. – user1934428 Feb 06 '24 at 09:42
  • @SolarMike : With other words, I have to ensure that my new Alt - command - w, when pressed inside i.e. the Chrome browser, is actually sending a Alt-Command-w to Chrome, and not ignoring it, or sending a Shift-Cmd-w followed by a Cmd-n. If I eventually come accross a different application where I want to configure Alt-Command-w, I have to put the logic into the same script. That script has to know what to do for each application. This is possible, but ugly from a design viewpoint. – user1934428 Feb 06 '24 at 09:45

1 Answers1

1

There is an extension called "close all tabs", which does exactly what I want:

  • Glad you found that - but it could have easily been done with an Automator Quick Action [Service], set to trigger on key command in only Firefox. – Tetsujin Feb 06 '24 at 12:35
  • 2
    @Tetsujin : I was not aware of Automator before, but it looks promising, and I think it can be of good use sooner or later. – user1934428 Feb 07 '24 at 11:55