Created
November 14, 2013 16:34
-
-
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.
This file contains hidden or 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
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