Skip to content

Commit

Permalink
Merge pull request #11 from quicksilver/tabs
Browse files Browse the repository at this point in the history
Tabs
  • Loading branch information
skurfer committed Jan 8, 2014
2 parents 36211b1 + 77614b0 commit 379720d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
27 changes: 16 additions & 11 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>2.3.0</string>
<string>2.3.1</string>
<key>CFBundleVersion</key>
<string>140</string>
<string>143</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2004, Blacktree, Inc.</string>
<key>QSActions</key>
Expand Down Expand Up @@ -108,7 +108,7 @@
<key>name</key>
<string>Run in Terminal […]</string>
<key>rankModification</key>
<real>2</real>
<real>2.0</real>
<key>validatesObjects</key>
<true/>
</dict>
Expand Down Expand Up @@ -202,7 +202,7 @@
<key>name</key>
<string>Run […]</string>
<key>rankModification</key>
<real>2</real>
<real>2.0</real>
<key>validatesObjects</key>
<true/>
</dict>
Expand All @@ -224,20 +224,20 @@
&lt;p&gt;The Terminal plugin allows Quicksilver to interact with the OS X Terminal; run commands and shell scripts, open directories in Terminal and more.&lt;/p&gt;
&lt;h3&gt;Actions&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt; Run […]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This action takes any script in Quicksilver&apos;s first pane (.sh, .pl, .command, .php, .py, .rb) and runs it in a Shell. An indirect argument is optional, meaning you can run any script with an argument by inputting text in Quicksilver&apos;s third pane. This differs from the &apos;Run in Terminal […]&apos; action in that it runs the script in a Shell, without opening a new Terminal window.&lt;/p&gt;
&lt;p&gt;This action takes any script in Quicksilver's first pane (.sh, .pl, .command, .php, .py, .rb) and runs it in a Shell. An indirect argument is optional, meaning you can run any script with an argument by inputting text in Quicksilver's third pane. This differs from the 'Run in Terminal […]' action in that it runs the script in a Shell, without opening a new Terminal window.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Run in Terminal […]&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The Run in Terminal […] action can be used on script files (for example, php, pl, sh, py files) to run these files as scripts in a new Terminal window. The action supports an optional extra argument, entered in Quicksilver&apos;s 3rd pane. This differs from the &apos;run […]&apos; action in that it opens a Terminal window, as opposed to running the script in a Shell.&lt;/p&gt;
&lt;p&gt;The Run in Terminal […] action can be used on script files (for example, php, pl, sh, py files) to run these files as scripts in a new Terminal window. The action supports an optional extra argument, entered in Quicksilver's 3rd pane. This differs from the 'run […]' action in that it opens a Terminal window, as opposed to running the script in a Shell.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Run Command in Shell&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Runs the item in Quicksilver&apos;s first pane in a shell, without launching Terminal. The item in Quicksilver&apos;s first pane should be a string (entered in Text Mode) of your desired command. If the command returns an item (for example, &lt;code&gt;ls&lt;/code&gt; returns a list of files and folders) they are returned to Quicksilver as text.&lt;/p&gt;
&lt;p&gt;Runs the item in Quicksilver's first pane in a shell, without launching Terminal. The item in Quicksilver's first pane should be a string (entered in Text Mode) of your desired command. If the command returns an item (for example, &lt;code&gt;ls&lt;/code&gt; returns a list of files and folders) they are returned to Quicksilver as text.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Run a Text Command in Terminal&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Similar to the &apos;Run Command in Shell&apos; action, but opens a new Terminal window and runs the command in the new window.&lt;/p&gt;
&lt;p&gt;Similar to the 'Run Command in Shell' action, but opens a new Terminal window and runs the command in the new window.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Open Directory in Terminal, Open Parent Directory in Terminal&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;These two actions open the folder or file selected in Quicksilver&apos;s first pane in Terminal. The name of the action depends on whether a folder or file is selected in Quicksilver&apos;s first pane.&lt;/p&gt;
&lt;p&gt;These two actions open the folder or file selected in Quicksilver's first pane in Terminal. The name of the action depends on whether a folder or file is selected in Quicksilver's first pane.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Show Man Page&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The &apos;Show Man Page&apos; action can be run on any executable file (typically found in &lt;code&gt;/usr/bin&lt;/code&gt; or &lt;code&gt;/usr/local/bin&lt;/code&gt;). It opens a new window with the &apos;man&apos; page for the selected executable.&lt;/p&gt;
&lt;p&gt;The 'Show Man Page' action can be run on any executable file (typically found in &lt;code&gt;/usr/bin&lt;/code&gt; or &lt;code&gt;/usr/local/bin&lt;/code&gt;). It opens a new window with the 'man' page for the selected executable.&lt;/p&gt;
&lt;h3&gt;Catalog Preset&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Bash Command History&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This &lt;a href=&quot;qs://preferences#QSCatalogPrefPane&quot;&gt;Catalog&lt;/a&gt; Preset, found under &apos;Plugins &amp;gt; Bash Command History&apos; adds your bash history to the Quicksilver catalog (more accurately, it adds the contents of &lt;code&gt;~/.bash_history&lt;/code&gt; to your catalog).&lt;/p&gt;</string>
&lt;p&gt;This &lt;a href="qs://preferences#QSCatalogPrefPane"&gt;Catalog&lt;/a&gt; Preset, found under 'Plugins &amp;gt; Bash Command History' adds your bash history to the Quicksilver catalog (more accurately, it adds the contents of &lt;code&gt;~/.bash_history&lt;/code&gt; to your catalog).&lt;/p&gt;</string>
<key>icon</key>
<string>com.apple.Terminal</string>
<key>relatedPaths</key>
Expand Down Expand Up @@ -306,5 +306,10 @@
<string>Mediator</string>
</dict>
</dict>
<key>QSRequirements</key>
<dict>
<key>version</key>
<string>4001</string>
</dict>
</dict>
</plist>
9 changes: 5 additions & 4 deletions QSTerminalMediator.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ - (void)performCommandInTerminal:(NSString *)command{
TerminalTab *tab = [[[[t classForScriptingClass:@"tab"] alloc] init] autorelease];
[[frontmost tabs] insertObject:tab atIndex:0];
*/
BOOL terminalRunning = [t isRunning];

[t activate];
// developer feature!
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QSTerminalUseTabs"]) {

BOOL terminalRunning = [t isRunning];
usleep(terminalRunning ? 10000 : 250000);

TerminalWindow *frontmost = nil;
SBElementArray *windows = [t windows];
Expand All @@ -54,7 +55,7 @@ - (void)performCommandInTerminal:(NSString *)command{
frontmost = [windows objectAtIndex:[frontmostIndex lastIndex]];
}

if (terminalRunning) {
if (terminalRunning && frontmost) {
// simulate CMD-T.
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStatePrivate);
CGEventRef keyDown = CGEventCreateKeyboardEvent (source, (CGKeyCode)17, true); //T
Expand All @@ -67,12 +68,12 @@ - (void)performCommandInTerminal:(NSString *)command{
CFRelease(keyDown);
CFRelease(keyUp);
CFRelease(source);
usleep(10000);
}
[t doScript:command in:frontmost];
} else {
// in the future we should be able to use 'in:tab' to do the script in our new tab... if/when Tabs work in AS/SB
[t doScript:command in:nil];
}
[t activate];
}
@end

0 comments on commit 379720d

Please sign in to comment.