Close tabs to the right for Safari

Chrome has a terrific feature that lets you close all the tabs to the right of the current one. Very handy if you’ve opened a bunch of links from search results, found the one you want, and want to get rid of all the rest. Safari is a bit more limited; you can only close all but the current tab. You can get around that via Applescript.

First, make sure “Show Script menu in menu bar” is checked in the Applescript Editor preferences. Enter the following script into Applescript Editor, and save it to ~/Library/Scripts/Applications/Safari.

tell window 1 of application "Safari"
    close (tabs where index > (get index of current tab))
end

If you wanted to be able to assign a keyboard shortcut for this, you can turn the script into a service using ThisService, and assign the shortcut in the Keyboard Preferences Pane.

(via Ask Different)

Comments are closed here.