Created
August 16, 2012 01:36
-
-
Save pztrick/3365452 to your computer and use it in GitHub Desktop.
ST2 Terminal plugin hack for Git Bash terminal
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
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