diff --git a/Side Bar.sublime-menu b/Side Bar.sublime-menu new file mode 100644 index 0000000..4bbd321 --- /dev/null +++ b/Side Bar.sublime-menu @@ -0,0 +1,10 @@ +[ + { + "id": "SublimeGitUp", "caption": "-" + }, + { + "caption": "Open in GitUp", + "command": "side_bar_gitup", + "args": { "paths": [] } + } +] diff --git a/SublimeGitUp.py b/SublimeGitUp.py index c6c773e..61d3dc4 100644 --- a/SublimeGitUp.py +++ b/SublimeGitUp.py @@ -26,3 +26,26 @@ def run(self, *args): app_path = '/Applications/GitUp.app' subprocess.call(['open', '-a', app_path, path]) + +class SideBarGitupCommand(sublime_plugin.WindowCommand): + + def is_enabled(self): + return True + + def get_path(self, paths): + try: + return paths[0] + except IndexError: + return self.window.active_view().file_name() + + def run(self, paths): + sublime.status_message('GitUp: running') + path = self.get_path(paths) + if not path: + sublime.status_message('GitUp: No path') + return False + if os.path.isfile(path): + path = os.path.dirname(path) + + app_path = '/Applications/GitUp.app' + subprocess.call(['open', '-a', app_path, path])