Switching tabs in Safari 4 with shortcuts, just like in Firefox

As a heavy-user of Firefox, the biggest annoyance in Safari for me was the missing shortcuts for directly accessing tabs. In Firefox you can access the tabs by pressing Cmd+<number of tab>. For example, if you want to jump to your third tab you would press Cmd + 3 (⌘ + 3), however in Safari this loads the third bookmark from the bookmark toolbar - very annoying if you are used to a different behavior.

Luckily there is a way to change this behavior and make Safari (4, not sure about 3) behave like Firefox with the help of this innocent looking piece of AppleScript:

tell front window of application "Safari" to set current tab to tab 3

Simple, isn't it? Now, all we need to do is to figure out how to combine this script with the shortcuts. Thankfully there's a small and free application called FastScripts Lite (hidden on the bottom of that page), it's limited to ten shortcuts, but all we want are nine (since Cmd + 0 is assigned to a somewhat useful "Actual Size" function), so it's perfect. If you need more shortcuts, you can purchase the full version.

Let's review that AppleScript above to ignore any errors caused by non-existing tabs:

	tell front window of application "Safari" to set current tab to tab 3
on error
	tell front window of application "Safari" to set current tab to last tab
end try

Open Script Editor and create nine files from 1-9 in ~/Library/Scripts/Applications/Safari, let's call them Tab1.scpt to Tab9.scpt and paste in each file the script from above, changing the 3 at the end of the long line to the current number. I have prepared a Zip with all nine files (, so you don't need to do this by yourself. Simply extract this file in ~/Library/Scripts/Applications/.

Next, launch FastScripts, click on the icon in the toolbar at the top of the screen and go to FastScripts->Preferences:

1. We want FastScripts to start when we log in.

2. Assign Cmd+1 - Cmd+9 (or any other combinations) to the proper Tab-scripts

Go back to Safari, and see the magic at work!


wow! I was looking for this in a -real- long time! tnx!

absolutely brilliant! thanks so much!

Very good article! Helped me a lot! :)

thank you! this is a brilliant workaround!! cheers!

Thank you so much! Now i can go for safari insted! But there is a problem..The other apps, for example VLC, does not longer work with the shortcuts. Like "Fit to screen" (cmd+3).

Im not good att apple scripts att all, is there a way to make it work again with the apple script for safari on?


Fred, this is very strange. Did you set it up as described? the scripts should be in ../Library/Scripts/Applications/Safari. That way they will only be active if Safari is in front, but otherwise don't do anything.

Thanks Paul! That fixed it. I just had them in Library/Scripts/Safari. I did not have a Applications folder so I created one now. Didn't thought it would make a difference. Thank for your help! Your great!

Awesome! works great!

You can also use Quicksilver and add the scripts as a new hotkey trigger.

thx a lot!

Works great using Butler as well! Thanks for the scripts!

I used to use Cmd + 1 and Cmd + 2 to switch between previous and next tabs in Opera and Camino, is there a way to do this in Safari, Firefox and Chrome?
I find the numbered method to be cumbersome unless the tab number is visually indicated.

aa, why do you need any indication? First one is one, second two, third 3, fourth 4, etc... somehow i never had a problem with that.

But if you want to use cmd+1/2 to chnage tabs:

Got to System Preferences, Keyboard Shortcuts:

Check if there's already something predefined in "Application Keyboard Shortcuts" for, if not:

Click add (+), select "" from Menu, Menu Title: "Select Next Tab", in Menu Shortcut press Cmd + 2, Click "Add" and Repeat for "Select Previous Tab".

You are done and should be able to switch tabs with Cmd + 1/2 in Safari

Hi Paul,

I tried that method shortly after posting my comment, but it doesn't seem to override the application's shortcuts.

I don't need any indication per se, but it would make it quicker to identify the tabs, especially when you have 9 or more tabs open. What's more using Cmd + 9 for instance would require the use of both hands, which I don't want.

Just a matter of preference I guess =]

Thank you for posting this. Very helpful... I missed my cmd+ shortcuts!

thanks a lot! This is exactly what I wanted for so long.
This is way contrary to other areas of Mac OS like Terminal, Mail -- everywhere cmd+# does switching rather than creating new things. Not in Safari... until today!

Leave a comment

Creative Commons License
This weblog is licensed under a Creative Commons License.