Post 

Howto

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:

try
	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 (SafariTabs.zip), 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.
FastScripts1.jpg

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

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

7 Comments

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?

Thanks!

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!

Leave a comment

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by Movable Type 4.31-en