forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScriptTrigger.m
47 lines (38 loc) · 897 Bytes
/
ScriptTrigger.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// ScriptTrigger.m
// iTerm
//
// Created by George Nachman on 9/23/11.
//
#import "ScriptTrigger.h"
#import "RegexKitLite.h"
#import "NSStringITerm.h"
#include <sys/types.h>
#include <pwd.h>
@implementation ScriptTrigger
- (NSString *)title
{
return @"Run Command…";
}
- (BOOL)takesParameter
{
return YES;
}
- (NSString *)paramPlaceholder
{
return @"Enter command to run";
}
- (void)performActionWithValues:(NSArray *)values inSession:(PTYSession *)aSession
{
NSString *command = [self paramWithBackreferencesReplacedWithValues:values];
[NSThread detachNewThreadSelector:@selector(runCommand:)
toTarget:[self class]
withObject:command];
}
+ (void)runCommand:(NSString *)command
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
system([command UTF8String]);
[pool drain];
}
@end