enhance: add -WorkingDirectory and -Nologo arguments for PowerShell

This commit is contained in:
leo 2024-04-09 10:49:36 +08:00
parent 4882fd9d69
commit a3c81745aa

View file

@ -149,16 +149,13 @@ namespace SourceGit.Native
public void OpenTerminal(string workdir) public void OpenTerminal(string workdir)
{ {
var startInfo = new ProcessStartInfo(); if (string.IsNullOrEmpty(workdir) || !Path.Exists(workdir))
{
workdir = ".";
}
if (!string.IsNullOrEmpty(workdir) && Path.Exists(workdir)) var startInfo = new ProcessStartInfo();
{ startInfo.WorkingDirectory = workdir;
startInfo.WorkingDirectory = workdir;
}
else
{
startInfo.WorkingDirectory = ".";
}
switch (Shell) switch (Shell)
{ {
@ -167,7 +164,7 @@ namespace SourceGit.Native
var bash = Path.Combine(binDir, "bash.exe"); var bash = Path.Combine(binDir, "bash.exe");
if (!File.Exists(bash)) if (!File.Exists(bash))
{ {
App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Can NOT found bash.exe under '{binDir}'"); App.RaiseException(workdir, $"Can NOT found bash.exe under '{binDir}'");
return; return;
} }
@ -175,6 +172,7 @@ namespace SourceGit.Native
break; break;
case Models.Shell.PowerShell: case Models.Shell.PowerShell:
startInfo.FileName = _powershellPath; startInfo.FileName = _powershellPath;
startInfo.Arguments = $"-WorkingDirectory \"{workdir}\" -Nologo";
break; break;
case Models.Shell.CommandPrompt: case Models.Shell.CommandPrompt:
startInfo.FileName = "cmd"; startInfo.FileName = "cmd";
@ -183,7 +181,7 @@ namespace SourceGit.Native
startInfo.FileName = "wt"; startInfo.FileName = "wt";
break; break;
default: default:
App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Bad shell configuration!"); App.RaiseException(workdir, $"Bad shell configuration!");
return; return;
} }