File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -240,14 +240,18 @@ - (IBAction)executeCommandInTerminal:(id) __unused sender {
240
240
241
241
// test for iTerms newer scripting bridge
242
242
if (iTerm && [iTerm respondsToSelector: @selector (createWindowWithDefaultProfileCommand: )]) {
243
- iTerm2Window *terminal = nil ;
244
- iTerm2Session *session = nil ;
243
+ iTerm2Window *window = [iTerm createWindowWithDefaultProfileCommand: nil ] ;
244
+ iTerm2Session *session = [window currentSession ] ;
245
245
246
- if ([iTerm isRunning ]) {
247
- [iTerm createWindowWithDefaultProfileCommand: nil ];
246
+ int cnt = 0 ;
247
+ while ([[session text ] length ] == 0 ) {
248
+ if ( cnt++ > 100 ) {
249
+ NSLog (@" timeout reached" );
250
+ break ;
251
+ }
252
+ NSLog (@" wait for prompt..." );
253
+ [NSThread sleepForTimeInterval: 0 .01f ];
248
254
}
249
- terminal = [iTerm valueForKey: @" currentWindow" ];
250
- session = [terminal valueForKey: @" currentSession" ];
251
255
252
256
// write text "cd ~/whatever"
253
257
[session writeContentsOfFile: nil text: cdCommandString newline: true ];
You can’t perform that action at this time.
0 commit comments