Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-28 Thread Ron Hunsinger
On Jan 26, 2012, at 11:30 AM, Jens Alfke wrote: To work around this I suggest using single-quotes instead, and preprocessing the string to insert a backslash in front of any exclamation point or single-quote. I *think* that will be enough. After a single quote, the *only* character that

Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-28 Thread Jens Alfke
On Jan 28, 2012, at 1:17 AM, Ron Hunsinger wrote: After a single quote, the *only* character that has a special meaning is another single quote, which ends the quotation. …or a newline :) [And yes, I have encountered filenames with newlines in them. It happened after I downloaded a PDF

Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-26 Thread Andrew
I would like to perform the same logic as the New Terminal Tab at Folder service in Finder in my Cocoa app. The only code I found via Google is all using AppleScript to open the Terminal.app, but nothing I found was a Cocoa interface besides 3rd party terminal apps (iTerm, iTerm2). Is there a

Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-26 Thread Andrew
Well, I found this: http://code.google.com/p/cdto/source/browse/plugins/terminal/CD2Terminal.m?spec=svn20c4d028f197a6810230ddff969de81c4b23876dr=20c4d028f197a6810230ddff969de81c4b23876d And got the terminal opening in a new window at the path. So I now need to find how I can set the settings and

Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-26 Thread Andrew
Well, I figured it out for myself. Posting here in case anyone else wants to do the same: - (void)openTerminal:(id)sender { TerminalApplication* termApp = [SBApplication applicationWithBundleIdentifier:@com.apple.terminal]; NSString *dir = // Get your directory here NSString *cmd =

Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-26 Thread Jens Alfke
On Jan 26, 2012, at 9:13 AM, Andrew wrote: The only code I found via Google is all using AppleScript to open the Terminal.app, but nothing I found was a Cocoa interface besides 3rd party terminal apps (iTerm, iTerm2). Is there a better way than using NSAppleScript to do this? Not that I’m

Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-26 Thread Jens Alfke
On Jan 26, 2012, at 10:22 AM, Andrew wrote: NSString *cmd = [NSString stringWithFormat:@cd \%@\; clear”, dir]; // Assumes bash, which is okay for me, but maybe not others. Watch out — that line has quoting problems. If the path to the directory contains double-quotes, dollar signs,

Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-26 Thread Jean-Daniel Dupas
Le 26 janv. 2012 à 20:30, Jens Alfke a écrit : On Jan 26, 2012, at 10:22 AM, Andrew wrote: NSString *cmd = [NSString stringWithFormat:@cd \%@\; clear”, dir]; // Assumes bash, which is okay for me, but maybe not others. Watch out — that line has quoting problems. If the path to the