On Mac there's a visual window management tool called Exposé. On recent Macs, the default key is F3. (I think it used to be F11 on older MacBook keyboards.)
F3
: show all open windows
Ctrl F3
: show current application windows
Cmd F3
: hide all windows to show the desktop
Clicking on a window will bring it to the foreground.
While in Exposé, you can use the Tab key to switch apps and see their windows. Google "Exposé keyboard shortcuts" for more tricks.
You can assign the Exposé key and see the assigned shortcut keys in System Preferences.
Note: The following works up to OS X 10.7 but not in 10.8 – see this question.
Open up AppleScript Editor.app and paste the following:
on run argv
tell application "System Events"
if (name of processes) contains "Firefox" then
tell application "Firefox" to activate
keystroke "n" using command down
delay 0.1 -- UI scripting delay
else
tell application "Firefox" to activate
delay 0.3 -- more delay
end if
keystroke "l" using command down
keystroke item 1 of argv
keystroke return
end tell
end run
Here, we'll either open a new Window with Cmd-N, or just activate Firefox. I included a custom delay — this is necessary since UI actions have an inherent delay and the script would then type away even though the window wasn't ready yet.
Finally, we'll keystroke
the first argument, which is item 1 of argv
.
Save this file under firefox-window.scpt
, e.g. in your home folder. Then modify the shell function in ~/.bash_profile
:
function firefox-window() {
osascript ~/firefox-window.scpt "$1"
}
This will pass the first command line argument $1
to the AppleScript, to be accessed as item 1 of argv
.
Save the .bash_profile
and don't forget to restart your terminal or enter source ~/.bash_profile
. Then, simply run the command with:
firefox-window apple.com
firefox-window google.com
… et cetera.
Best Answer
Try unchecking the checkbox at the bottom in System Preferences » Exposé & Spaces.
Remember to set your browser to open links in new windows instead of new tabs of existing windows.