-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.DS_Store | ||
*~ | ||
tty.alfred3workflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
#!/usr/bin/env osascript -l JavaScript | ||
|
||
function getenv(name, value=null) { | ||
ObjC.import('stdlib') | ||
try { value = $.getenv(name); } | ||
finally { return value; } | ||
} | ||
|
||
function run(args) | ||
{ | ||
args = args.join(" ").split(" ").map(function(e,i){return i==0?String(e):Number(e)}); | ||
var app = Application("com.googlecode.iterm2"); | ||
var action = args[0]; | ||
var win = app.windows[args[1]]; | ||
var tab = win.tabs[args[2]]; | ||
var ses = tab.sessions[args[3]]; | ||
switch (action) { | ||
case "select": | ||
// tab => session => window => app | ||
tab.select(); | ||
ses.select(); | ||
win.select(); | ||
app.activate(); | ||
break; | ||
case "close": | ||
var old = win.currentTab(); | ||
tab.select(); | ||
ses.close(); | ||
old.select(); | ||
break; | ||
default: | ||
console.info(JSON.stringify({args:args, title:ses.name()})); | ||
break; | ||
args = args.join(" ").split(" ") | ||
var action = String(args[0]); | ||
if (action == "ssh") { | ||
var host = String(args[1] || ""); | ||
var alfred = Application("com.runningwithcrayons.Alfred-3"); | ||
alfred.runTrigger(getenv("ssh_trigger", "ssh"), | ||
{inWorkflow:getenv("ssh_workflow", "net.isometry.alfred.ssh"), withArgument:host}); | ||
} else { | ||
var iterm = Application("com.googlecode.iterm2"); | ||
var win = iterm.windows[Number(args[1])]; | ||
var tab = win.tabs[Number(args[2])]; | ||
var ses = tab.sessions[Number(args[3])]; | ||
switch (action) { | ||
case "select": | ||
// tab => session => window => app | ||
tab.select(); | ||
ses.select(); | ||
win.select(); | ||
iterm.activate(); | ||
break; | ||
case "close": | ||
var old = win.currentTab(); | ||
tab.select(); | ||
ses.close(); | ||
old.select(); | ||
break; | ||
default: | ||
console.info(JSON.stringify({args:args, title:ses.name()})); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters