Skip to content

Commit 3c0c96f

Browse files
committed
Fall back to default open terminal when git bash is not available
1 parent b857c91 commit 3c0c96f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

openbash/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44

55
import subprocess
66
import platform
7+
import os.path
78
from fman import DirectoryPaneCommand, show_alert, run_application_command, get_application_commands
89
from fman.url import splitscheme, as_human_readable
910

1011
class OpenBash(DirectoryPaneCommand):
1112
'''
1213
Open Bash
1314
'''
15+
16+
GIT_BASH = 'C:/Program Files/Git/git-bash.exe'
17+
1418
def __call__(self):
1519
url = self.pane.get_path()
1620
scheme, path = splitscheme(url)
1721
if scheme != 'file://':
1822
show_alert('Not supported.')
1923
return
2024
local_path = as_human_readable(url)
21-
if platform.system() == 'Windows':
22-
subprocess.call('C:/Program Files/Git/git-bash.exe --cd="{cd}"'.format(
25+
if platform.system() == 'Windows' and os.path.isfile(self.GIT_BASH):
26+
subprocess.call('{bash_exe} --cd="{cd}"'.format(
27+
bash_exe=self.GIT_BASH,
2328
cd=local_path))
2429
else:
25-
show_alert(
26-
"Sorry, this plugin is supposed to run on Windows. "
27-
"Use the built-in 'Open terminal' command on other platforms.")
30+
self.pane.run_command('open_terminal')

0 commit comments

Comments
 (0)