Skip to content

Instantly share code, notes, and snippets.

@pztrick
Created August 16, 2012 01:36
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 pztrick/3365452 to your computer and use it in GitHub Desktop.
Save pztrick/3365452 to your computer and use it in GitHub Desktop.
ST2 Terminal plugin hack for Git Bash terminal
def run_terminal(self, dir, parameters):
try:
if not dir:
raise NotFoundError('The file open in the selected view has ' +
'not yet been saved')
for k, v in enumerate(parameters):
parameters[k] = v.replace('%CWD%', dir)
args = [TerminalSelector.get()]
args.extend(parameters)
encoding = locale.getpreferredencoding(do_setlocale=True)
# Begin GitBash hackery
settings = sublime.load_settings('Terminal.sublime-settings')
gitbash = settings.get('gitbash')
if gitbash and os.name == 'nt':
subprocess.Popen(gitbash, cwd=dir.encode(encoding))
else:
# End GitBash Hackery
subprocess.Popen(args, cwd=dir.encode(encoding))
except (OSError) as (exception):
print str(exception)
sublime.error_message(__name__ + ': The terminal ' +
TerminalSelector.get() + ' was not found')
except (Exception) as (exception):
sublime.error_message(__name__ + ': ' + str(exception))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment