public Process RunBash(string bashCommand = null)
{
if (EnvUtils.RunningOnUnix())
{
string[] termEmuCmds =
{
"gnome-terminal",
"konsole",
"Terminal",
"xterm"
};
string args = "";
string cmd = termEmuCmds.FirstOrDefault(termEmuCmd => !string.IsNullOrEmpty(RunCmd("which", termEmuCmd)));
if (string.IsNullOrEmpty(cmd))
{
cmd = "bash";
args = "--login -i";
}
return RunExternalCmdDetachedShowConsole(cmd, args);
}
else
{
string shellPath;
if (PathUtil.TryFindShellPath("git-bash.exe", out shellPath))
{
return RunExternalCmdDetachedShowConsole(shellPath, string.Empty);
}
string args;
if (string.IsNullOrWhiteSpace(bashCommand))
{
args = "--login -i\"";
}
else
{
args = "--login -i -c \"" + bashCommand.Replace("\"", "\\\"") + "\"";
}
args = "/c \"\"{0}\" " + args;
if (PathUtil.TryFindShellPath("bash.exe", out shellPath))
{
return RunExternalCmdDetachedShowConsole("cmd.exe", string.Format(args, shellPath));
}
if (PathUtil.TryFindShellPath("sh.exe", out shellPath))
{
return RunExternalCmdDetachedShowConsole("cmd.exe", string.Format(args, shellPath));
}
return RunExternalCmdDetachedShowConsole("cmd.exe", @"/K echo git bash command not found! :( Please add a folder containing 'bash.exe' to your PATH...");
}
}