Jump to content

BrowserTabs (Chrome/Safari) - close tabs to the left/right, switch between tabs with keyboard


Recommended Posts

BrowserTabs Features

 

  • Close background windows in browser (Chrome/Safari)
  • Close all tabs to the right or left of the active tab in Safari and Google Chrome with a keyboard shortcut
  • Move to the next (right) / previous (left) tab with keyboard shortcuts
  • Move to the first or last tab in the Safari/Chrome window with keyboard shortcuts  

Install the workflow, add your own shortcuts for each command.

 

Skjermbilde%202013-06-04%20kl.%2015.19.1

Help for the keyboard shortcut setup:

 

  • closeLeftTabs - closes all tabs to the left
  • closeRightTabs - closes all tabs to the right

     

  • nextTab - switches to the next tab (to the right)
  • previousTab - switches to the previous tab (to the left)

     

  • lastTab - activates the first tab, to the left
  • firstTab - activates the last tab, to the right

 

  • closeBackgroundWindows - closes all background windows in Safari/Chrome
  • CloseOtherTabs - New feature (Google Chrome only): Close all other tabs with a keyboard shortcut

 

  • copyURL - copy the URL of the frontmost tab in Safari/Chrome to the clipboard
  • CopyURLandTitle - copy the URL and title of the frontmost tab in Safari/Chrome to the clipboard

Download BrowserTabs

 

Download BrowserTabs 1.22

 

Download BrowserTabs 1.23

 

(Optional: Download BrowserTabs 1.23.1 - additional shortcuts available for choosing tab 1 through 9 by individually shortcuts. Examples: cmd+option+1 for tab 1, cmd+option+2 for tab 2, etc)

Edited by MacGeeky
Link to comment
  • 4 weeks later...
  • 2 weeks later...

MacGeeky - this is awesome, thank you for creating it.

 

One suggestion/request for you would be to create additional shortcut options so that tabs 2-9 can be directly selected via keyboard shortcut as well (like Chrome/Firefox does it, and Safari does not).  I'm not savvy enough to edit your 'firstTab' shortcut to do the others, but if you could add them I'd be quite grateful.  

 

Just in case that's not clear, what I'm talking about is:

 

FirstTab = Command-1 (or whatever custom shortcut a user wants)

SecondTab = Command-2 (or custom)

etc..

Thanks again for posting.  It's a really useful workflow.

Link to comment

myrison - I could make a version for you with these options, but I don't think I'll implement it in the official version because the setup would be too cluttered in my opinion.

 

I'll make a special version for you, and post it when it finished :)

 

Here's a new version with support for choosing between the first 9 tabs in Chrome/Safari with a shortcut.

 

Download BrowserTabs (with support for choosing tabs by number)

Edited by MacGeeky
Link to comment

Thanks a ton.  This is hugely useful for me (and hopefully a few other people as well).  

 

Hopefully future googlers are able to find their way here.  I know from searching for a solution before coming here that there are at least a few people looking for this same implementation. 

 

I'll post links where I can to provide more exposure to Alfred and your script MacGeeky.  Let me know if I can buy you a beer. :)

Link to comment
  • 5 months later...
  • 5 months later...

This script is great but way too hotkey intensive for me to use as much as I'd like.

 

- Anyway to get a scriptfilter set to optional? Start typing and you filter down the list to the command your looking for but in this way not necessary to remember the variables or the hotkeys as they are listed automatically in alfred's menu...

 

That would make this so much more useful for me. I will play around some more and see if I can get it working off the example of another workflow but I tried before and got discouraged so I'll let you know but 1+ days you can be sure I have threw in the towel. Cheers!

Link to comment
  • 2 months later...
  • 4 weeks later...
  • 4 weeks later...

Hmm, it doesn't work for me... No action I set does really do anything in Safari for me (MBP 2009, Mavericks).

Did something change or is it still working for you guys?

 

I haven't updated the extension for 10.9 yet, but I'm (only) assuming it's related to the change in security and Accessability Preferences - you have to manually accept each application that uses GUI scripting (this extension does) in Preferences => Accessability. Here's Apples support page for this solution: http://support.apple.com/kb/HT6026

Edited by MacGeeky
Link to comment
  • 1 year later...

Greetings,

I have a new Mac and I'm trying to use a workflow with Alfred 3 called Browsertabs that, among other things, closes all Safari tabs to the left or to the right. This workflow works fine on two of my Macs (all running El Capitan). I Exported it from a working version of Alfred 3 and then Imported it to the new Mac by double clicking on it.

 

After I add a shortcut key combination, I get this error:

Starting debug for 'BrowserTabs'

 

[2016-08-14 11:45:25][trigger.hotkey] Processing output of 'action.applescript' with arg 'closeRightTabs'

[2016-08-14 11:45:25][ERROR: action.applescript] {

    NSAppleScriptErrorBriefMessage = "Expected end of line, etc. but found property.";

    NSAppleScriptErrorMessage = "Expected end of line, etc. but found property.";

    NSAppleScriptErrorNumber = "-2741";

    NSAppleScriptErrorRange = "NSRange: {2239, 3}";

 

Any suggestion?

Steve

Link to comment

This is the link http://www.alfredforum.com/topic/2580-browsertabs-chromesafari-close-tabs-to-the-leftright-switch-between-tabs-with-keyboard/

 

The first time I ran it with Safari open I got a window asking where Chrome was located. I don't have Chrome on this Mac.

 

This is the AppleScript

on alfred_script(q)

 
-- find front app
tell application "System Events"
set frontApp to name of the first process whose frontmost is true
 
end tell
 
 
if frontApp is "Safari" then
 
if q is "tab1" then
tell first window of application "Safari" to set current tab to tab 1
else if q is "tab2" then
tell first window of application "Safari" to set current tab to tab 2
else if q is "tab3" then
tell first window of application "Safari" to set current tab to tab 3
else if q is "tab4" then
tell first window of application "Safari" to set current tab to tab 4
else if q is "tab5" then
tell first window of application "Safari" to set current tab to tab 5
else if q is "tab6" then
tell first window of application "Safari" to set current tab to tab 6
else if q is "tab7" then
tell first window of application "Safari" to set current tab to tab 7
else if q is "tab8" then
tell first window of application "Safari" to set current tab to tab 8
else if q is "tab9" then
tell first window of application "Safari" to set current tab to tab 9
end if
 
else if frontApp is "Google Chrome" then
 
if q is "tab1" then
tell application "Google Chrome" to set active tab index of first window to 1
else if q is "tab2" then
tell application "Google Chrome" to set active tab index of first window to 2
else if q is "tab3" then
tell application "Google Chrome" to set active tab index of first window to 3
else if q is "tab4" then
tell application "Google Chrome" to set active tab index of first window to 4
else if q is "tab5" then
tell application "Google Chrome" to set active tab index of first window to 5
else if q is "tab6" then
tell application "Google Chrome" to set active tab index of first window to 6
else if q is "tab7" then
tell application "Google Chrome" to set active tab index of first window to 7
else if q is "tab8" then
tell application "Google Chrome" to set active tab index of first window to 8
else if q is "tab9" then
tell application "Google Chrome" to set active tab index of first window to 9
end if
end if
end alfred_script
Link to comment

The first time I ran it with Safari open I got a window asking where Chrome was located. I don't have Chrome on this Mac.

I think that breaks the workflow. AppleScript chokes if there's a "tell" clause whose target application isn't installed. Unless someone has a better idea, you could try installing Chrome or removing the parts of the workflow that refer to it.

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...