Jump to content

SSH with smart hostname autocompletion

Recommended Posts

user.workflow.3ACC632C-5489-45C1-92AA-6FC07DC4B472 yossarian$ python -c 'import alfredssh; print alfredssh.complete("local");'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "alfredssh.py", line 137, in complete
  File "alfredssh.py", line 83, in fetch_known_hosts
IndexError: list index out of range

^^ First command - fwiw, my python version when running that command is 2.7.8. The /usr/bin version is 2.7.5 and gives me the same output.


OK. It looks like your ~/.ssh/known_hosts contains a line that the workflow couldn't handle: most likely a blank line (with which I reproduced the error). I've updated it to handle blanks at GitHub and Packal: download

Thanks for reporting the issue!

Bonus fix: it also now ignores encrypted entries in ~/.ssh/known_hosts.

Edited by isometry
Link to comment
  • 3 weeks later...

Any chance of being able to configure this workflow to open in a new tab instead of a new window? Would work better with TotalTerminal: http://totalterminal.binaryage.com/


Are you aware of iTerm2's Hotkey Window? It provides arguably more powerful functionality to that of TotalTerminal, and iTerm2's default behaviour as ssh protocol handler is "Open in a New Tab". Performance improvements over the past year combined with the addition of Infinite Scrollback leave me little reason to fallback to Terminal.app or hacking SIMBL plugins :-)

Link to comment

Ok, if anyone else is curious, I opened a question at StackExchange:




We'll see if that bears any fruit.

Like the SE thread says, your best bet is to create a "wrapper" application in Automator and fiddle with its Info.plist to make the app an ssh:// handler. Then you can use AppleScript in the app to tell whichever terminal app you like to open ssh:// URLs the way you want.

This is quite a useful pattern, and I've done something similar with Sublime Text, creating a wrapper app to open .sublime-project files with the subl CLI app.

Link to comment
  • 1 year later...
  • 2 weeks later...

Same problem here, solved by following these instructions:




Perfect. Thanks, @okapi!

I was thinking I'd like to update to using the Alfred 2.4+ environment variables, but your tracking use of static paths down to a real issue gave me the impetus to actually do so.

The workflow has now been updated with enhanced Alfred 3 compatibility and is available on GitHub, here and on Packal.

Link to comment
  • 2 years later...
36 minutes ago, Anmol Nagpal said:


I"m trying to make it will iTerm, which I did use the link in Readme. But when I'm opening via Alfred iTerm start but then it closes itself 


That's what iTerm does when the connection fails. Are you sure the machine is responsive and the connection details are correct?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...