Re: Cocoa-dev Digest, Vol 9, Issue 161
Re: Cocoa-dev Digest, Vol 9, Issue 161
- Subject: Re: Cocoa-dev Digest, Vol 9, Issue 161
- From: John Maisey <email@hidden>
- Date: Thu, 08 Mar 2012 14:47:58 +0000
Hi,
The 'do script' command opens a new shell window. From Terminal's Applescript dictionary:
do script v : Runs a UNIX shell script or command.
This script opens a new window always.
tell application "Terminal"
activate
do script
end tell
The previous window when the applications opens will be stored from the previous session that Terminal.app was opened. If you don't want to see it, you could check to see if the Terminal.app is running and if it is not close all windows once you activate it In the NSAppleScript command.
Best wishes
John Maisey
----
www.nhoj.co.uk
www.twitter.com/johnmaisey
www.facebook.com/nhojcouk
On 8 Mar 2012, at 05:19, email@hidden wrote:
> Subject: Why are 2 Terminal windows opening with NSAppleScript?
>
> If no Terminal app is open, the following code opens TWO Terminal windows. Why is it doing this? I only want one window to open.
>
> If only one Terminal window is open, then the following code opens only ONE additional window.
>
> NSAppleScript* terminal = [[NSAppleScript alloc] initWithSource:
> [NSString stringWithFormat:
> @"tell application \"Terminal\"\n"
> @" activate\n"
> @" do script \"echo %@\"\n"
> @" tell the front window\n"
> @" set title displays shell path to false\n"
> @" set title displays custom title to true\n"
> @" set custom title to \"My session! %@\"\n"
> @" end tell\n"
> @"end tell", name, name]];
>
> [terminal executeAndReturnError:nil];
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden