Jump to content
isometry

^tty - iTerm search and control with alfred-ssh fall-through

Recommended Posts

A JXA-based workflow for Alfred 3 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 and deanishe/alfred-ssh).

 

GitHub: https://github.com/isometry/alfred-tty

Latest Release: https://github.com/isometry/alfred-tty/releases/latest

Usage

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.

 

matches.thumb.png.12a164216aa92c4c1105c603ca9e369d.png

 

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, version 2.3+). Override by setting the ssh_workflow and ssh_trigger variables; for deanish/alfred-ssh, set the ssh_workflow variable to net.deanishe.alfred-ssh.

 

no_match.thumb.png.57c3852fcbd56e50ac7460eadfc0b8f8.png

 

In order to make working with more than one window/tab/pane with the same title easier, the tty is displayed beneath the result, and can be provided as a second argument to the trigger. For example, enter tty lo 3 to select the the session with title localhost running on /dev/ttys003.

 

To select by tty alone, use two spaces between the trigger and the tty number. For example, tty  4 will select /dev/ttys004.

 

Optionally associate a hotkey trigger to further accelerate operation, e.g. Ctrl+Cmd+T, or change the trigger word via the keyword variable.

 

Combine with an iTerm2 profile configured as ssh protocol handler (e.g. Name:=$$USER$$@$$HOST$$, Command:=$$ and Schemes handled:=ssh) and an alfred-ssh workflow to make opening and jumping between remote sessions across many windows, tabs and panes easy.

Share this post


Link to post

Ho ho. This is totally awesome!

 

I love that it picks up individual TTYs, and not just iTerm tabs (I tend to always run split tabs, with a shell on one side and a test server on the other).

 

So good!

 

Share this post


Link to post

1) It lists the tabs/panes, but Enter does not activate iTerm for me.

Debug says this:

 

action-tty.js:1:36: script error: Error on line 2: SyntaxError: Unexpected token '='. Expected a ')' or a ',' after a parameter declaration. (-2700)

 

iTerm2 (Build 3.1.20170905-nightly)

Alfred3 (latest)

OSX 10.11.6

 

2) Also, see attached screenshot,  any idea why it doesn't fill the available space? Almost every entry is cut off (oh actually in most only the path is cut-off, but I would prefer to see it, or part of it, if there's space).

 

3) See that npm (node) line in the screenshot? Is it possible for it to be searchable by the working directory it's running from?

 

Thanks

 

tty.png

Edited by Maddog

Share this post


Link to post
15 hours ago, Maddog said:

1) It lists the tabs/panes, but Enter does not activate iTerm for me.

 

Thanks for the bug report. I suspect an incompatibility with my JXA code and OSX 10.11; I'd only tested on 10.12 and 10.13 beta. I'm firing up a VM to investigate.

 

Update: Please try my v1.2-beta1 pre-release for OSX 10.11 compatibility!

 

Quote

2) Also, see attached screenshot,  any idea why it doesn't fill the available space? Almost every entry is cut off (oh actually in most only the path is cut-off, but I would prefer to see it, or part of it, if there's space).

 

I display the full session title as reported by iTerm2. In your case, I can only surmise that your sessions have tabs/sessions have been set as displayed. I suggest you refer to the iTerm2 FAQ and customise your shell to a title that better matches your needs.

 

Quote

3) See that npm (node) line in the screenshot? Is it possible for it to be searchable by the working directory it's running from?

 

Unfortunately, iTerm2 doesn't expose the working directory, so this is unavailable to filter on without further effort on your part. I would suggest customising your tab titles through your shell (as above) to include the information you want to search on, or if they're long-running tweaking them manually with Cmd+I.

 

The entire scrollback history is available, and I did play with filtering history (and the last line/screen of output, which commonly includes working directory). Unfortunately, performance goes down the drain as soon as you have a single pane with significant scrollback (I tend to run with unlimited scrollback), rendering the entire workflow unusable; I suppose I could expose this behind a default-disabled feature flag for those that don't rely on a large scrollback, but I'm not convinced it would be that useful… if anyone seriously thinks otherwise, log a feature request.

Edited by isometry

Share this post


Link to post
10 hours ago, isometry said:

 

Thanks for the bug report. I suspect an incompatibility with my JXA code and OSX 10.11; I'd only tested on 10.12 and 10.13 beta. I'm firing up a VM to investigate.

 

Update: Please try my v1.2-beta1 pre-release for OSX 10.11 compatibility!

 

 

Thank you, it works now! Very good

 

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...