Reputation: 29519
tell application "Terminal"
activate
if windows is {} then reopen
do script "ssh [email protected]" in window 1
end tell
How can I tell apple script if there are open windows, to open new window as well, because it can ruin existing one.
Upvotes: 1
Views: 750
Reputation: 11238
This is cleaner...
tell application "Terminal"
if not (exists window 1) then reopen
activate
do script "ssh [email protected]" in window 1
end tell
Upvotes: 2
Reputation: 3292
If you don't target a window by index it will open a new window every time.
e.g,
tell application "Terminal"
activate
do script "ssh [email protected]"
end tell
or to deal with using existing windows on a fresh open.
tell application "System Events"
if (count (processes whose bundle identifier is "com.apple.Terminal")) is 0 then
tell application "Terminal"
activate
do script "ssh [email protected]" in window 0
end tell
else
tell application "Terminal"
do script "ssh [email protected]"
activate
end tell
end if
end tell
more ideas here: http://hintsforums.macworld.com/archive/index.php/t-68252.html
Upvotes: 0