Skip to content

Instantly share code, notes, and snippets.

@lcarva
Created August 27, 2019 12:50
Show Gist options
  • Save lcarva/e3fc1b59e5e81d1ce01ca52e652a553c to your computer and use it in GitHub Desktop.
Save lcarva/e3fc1b59e5e81d1ce01ca52e652a553c to your computer and use it in GitHub Desktop.
Terminator plugin to turn JIRA issue identifiers into a link
from terminatorlib import config, plugin
AVAILABLE = ['JiraIssueURLHandler']
DEFAULT_JIRA_URL = 'https://jira.atlassian.com/browse'
DEFAULT_MATCH = '[A-Z0-9]{3,}-[0-9]{3,}'
class JiraIssueURLHandler(plugin.URLHandler):
capabilities = ['url_handler']
handler_name = 'jira_issue'
def __init__(self):
self.plugin_name = self.__class__.__name__
self.config = config.Config()
self.check_config()
self.match = self.config.plugin_get(self.plugin_name, 'match')
if hasattr(self.match, 'decode'):
self.match = self.match.decode('string_escape')
def check_config(self):
config = {
'jira_url': DEFAULT_JIRA_URL,
'match': DEFAULT_MATCH,
}
saved_config = self.config.plugin_get_config(self.plugin_name)
if saved_config is not None:
config.update(saved_config)
self.config.plugin_set_config(self.plugin_name, config)
self.config.save()
def callback(self, url):
return '%s/%s' % (self.config.plugin_get(self.plugin_name, 'jira_url'), url)
@lcarva
Copy link
Author

lcarva commented Aug 27, 2019

See Terminator's docs for installing plugins.

After copying the file to the correct plugin dir, Terminator must be restarted. At that point, ~/.config/terminator/config will be updated to include the default configuration options. You'll want to update the jira_url value if a different Jira instance is being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment