Skip to content

Instantly share code, notes, and snippets.

@oparrish
Created November 14, 2013 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oparrish/7469896 to your computer and use it in GitHub Desktop.
Save oparrish/7469896 to your computer and use it in GitHub Desktop.
AutoKey (https://code.google.com/p/autokey/) script to open a new tab in Terminator with SSH to selected IP.
import subprocess
import re
try:
host = clipboard.get_selection()
host = host.strip()
pattern = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
validHost = pattern.match(host)
if validHost:
subprocess.call(['terminator','--new-tab', '-e', 'ssh %s' % host])
window.activate('terminator.Terminator',False,True)
else:
raise Exception("Invalid host selected")
except Exception as e:
error_message=str(e)
if error_message == "No text found in X selection":
error_message = "No host selected"
dialog.info_dialog("Error", error_message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment