Skip to content

Commit

Permalink
Improved Alfred 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
isometry committed Dec 26, 2019
1 parent 9aa98b5 commit 07b6a7b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
all:
zip -j9 --filesync tty.alfred3workflow *.{plist,png,js}
zip -j9 --filesync tty.alfredworkflow *.{plist,png,js}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A JXA-based workflow for [Alfred](http://www.alfredapp.com/) Powerpack users to quickly switch between or close iTerm windows, tabs and panes based on title and tty, or trigger your preferred ssh workflow when no open session is found (supports both [isometry/alfred-ssh](https://github.com/isometry/alfred-ssh) and [deanishe/alfred-ssh](https://github.com/deanishe/alfred-ssh)).

## Releases
- [Latest for Alfred 3.x](https://github.com/isometry/alfred-tty/releases/latest)
- [Latest for Alfred 3.x/4.x](https://github.com/isometry/alfred-tty/releases/latest)

## Requirements

Expand Down
40 changes: 20 additions & 20 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ function run(args) {
var app, action = String(args[0]);
if (action == "ssh") {
var host = String(args[1] || "");
app = Application("com.runningwithcrayons.Alfred-3");
app = Application("com.runningwithcrayons.Alfred");
app.runTrigger(getenv("ssh_trigger", "ssh"), {
inWorkflow:getenv("ssh_workflow", "net.isometry.alfred.ssh"),
withArgument:host
inWorkflow: getenv("ssh_workflow", "net.isometry.alfred.ssh"),
withArgument: host
});
} else {
app = Application(getenv("iterm_application", "com.googlecode.iterm2"));
app.strictPropertyScope = true;
app.strictCommandScope = true;
app.strictCommandScope = true;
app.strictParameterType = true;
var win = app.windows.byId(Number(args[1]));
var tab = win.tabs[Number(args[2])];
var ses = tab.sessions.byId(String(args[3]));
switch (action) {
case "select":
// tab => session => window => app
tab.select();
ses.select();
win.select();
app.activate();
break;
case "close":
ses.close();
break;
case "debug":
console.log(JSON.stringify({args:args, title:ses.name()}));
break;
default:
console.log("Invalid arguments:", JSON.stringify(args));
break;
case "select":
// tab => session => window => app
tab.select();
ses.select();
win.select();
app.activate();
break;
case "close":
ses.close();
break;
case "debug":
console.log(JSON.stringify({ args: args, title: ses.name() }));
break;
default:
console.log("Invalid arguments:", JSON.stringify(args));
break;
}
}
}
8 changes: 5 additions & 3 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>1</integer>
<key>argumenttype</key>
Expand Down Expand Up @@ -90,7 +92,7 @@
<key>uid</key>
<string>C9298943-AE22-4585-8C3B-4A3E72EEAAA4</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
Expand Down Expand Up @@ -148,7 +150,7 @@
</dict>
</array>
<key>readme</key>
<string> Trigger the workflow with the keyword `tty`, or via hotkey, followed by some characters from the title of an open window, tab or pane; press `Enter` to activate the selected window/tab/pane, `Alt-Enter` to close it, or `Cmd-Enter` to trigger your ssh workflow. For example, enter `tty as3` to switch to a tab with the title `user@azure-server-03`.
<string>Trigger the workflow with the keyword `tty`, or via hotkey, followed by some characters from the title of an open window, tab or pane; press `Enter` to activate the selected window/tab/pane, `Alt-Enter` to close it, or `Cmd-Enter` to trigger your ssh workflow. For example, enter `tty as3` to switch to a tab with the title `user@azure-server-03`.
If no active terminal matches, or you use the `Cmd`-modifier, trigger your preferred ssh workflow, e.g. `⇄ ssh as3`.
By default, the ssh workflow is assumed to be `net.isometry.alfred.ssh` (i.e. [isometry/alfred-ssh](https://github.com/isometry/alfred-ssh), version 2.3+). Override by setting the `ssh_workflow` and `ssh_trigger` variables; for [deanishe/alfred-ssh](https://github.com/deanishe/alfred-ssh), set the `ssh_workflow` variable to `net.deanishe.alfred-ssh`.
Expand Down Expand Up @@ -210,7 +212,7 @@ Combine with an [iTerm2](https://www.iterm2.com/) profile configured as ssh prot
<string>net.isometry.alfred.ssh</string>
</dict>
<key>version</key>
<string>1.4</string>
<string>1.5</string>
<key>webaddress</key>
<string>https://github.com/isometry/alfred-tty</string>
</dict>
Expand Down

0 comments on commit 07b6a7b

Please sign in to comment.