One thing that really bugs me about Safari is the inability to have a keyboard shortcut for each tab. In Firefox, you can use Command-1 to get the first tab, Command-2 to get the second tab, and so on. (You can cycle between all open tabs with Command-{ and Command-}, but you can't just to a specific tab.) With the release of Safari 3, there is now AppleScript support for selecting tabs. To select tab 1 you can do this:
tell front window of app "Safari" to set current tab to tab 1
I wrote nine similar scripts for tabs one through nine, and a script for activating the last tab. These go in ~/Library » Scripts » Applications » Safari. Then I assigned each script to a trigger in Quicksilver that is only available when Safari is active. If you have the scripts menu active, you should be able to assign keyboard shortcuts to each file. However, these shortcuts don't work for me within Safari for some reason. Perhaps someone else can figure this one out.
The following script should generate the AppleScripts for you:
#!/usr/bin/env bash
SAFARI_SCRIPTS_PATH="$HOME/Library/Scripts/Applications/Safari"
mkdir -p "$SAFARI_SCRIPTS_PATH"
# tabs 1-9
for (( i = 1; i < 10; i++ )); do
script_filename="$SAFARI_SCRIPTS_PATH/Activate Tab $i"
osascript<<-EOF
script setTab
tell front window of app "Safari" to set current tab to tab $i
end script
store script setTab in posix file "$script_filename" replacing yes
EOF
echo "Created $script_filename"
done
# last tab
script_filename="$SAFARI_SCRIPTS_PATH/Activate Last Tab"
osascript<<-EOF
script setTab
tell front window of app "Safari" to set current tab to last tab
end script
store script setTab in posix file "$script_filename" replacing yes
EOF
echo "Created $script_filename"
echo "Done"
[robg adds: The shell script (and the AppleScripts it created) worked for me with Safari 3.0.3. To use the shell script, copy and paste the text into your favorite pure text editor, save it somewhere convenient, then cd to that directory in Terminal. Make your script executable (chmod a+x script_name), and then execute it (./script_name).]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20070730145747991