Skip to content

Commit

Permalink
fix some iTerm related timing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
muhqu committed Sep 27, 2019
1 parent 109ae65 commit ef4ad4d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Term Window/DTTermWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,18 @@ - (IBAction)executeCommandInTerminal:(id) __unused sender {

// test for iTerms newer scripting bridge
if(iTerm && [iTerm respondsToSelector:@selector(createWindowWithDefaultProfileCommand:)]) {
iTerm2Window *terminal = nil;
iTerm2Session *session = nil;
iTerm2Window *window = [iTerm createWindowWithDefaultProfileCommand:nil];
iTerm2Session *session = [window currentSession];

if([iTerm isRunning]) {
[iTerm createWindowWithDefaultProfileCommand:nil];
int cnt = 0;
while ([[session text] length] == 0) {
if ( cnt++ > 100 ) {
NSLog(@"timeout reached");
break;
}
NSLog(@"wait for prompt...");
[NSThread sleepForTimeInterval:0.01f];
}
terminal = [iTerm valueForKey:@"currentWindow"];
session = [terminal valueForKey:@"currentSession"];

// write text "cd ~/whatever"
[session writeContentsOfFile:nil text:cdCommandString newline:true];
Expand Down

0 comments on commit ef4ad4d

Please sign in to comment.