From a3c81745aa23a957281b7926b3bd78244c4144b5 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 9 Apr 2024 10:49:36 +0800 Subject: [PATCH] enhance: add -WorkingDirectory and -Nologo arguments for PowerShell --- src/Native/Windows.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index fbcdb0bf..a14b6cc7 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -149,16 +149,13 @@ namespace SourceGit.Native public void OpenTerminal(string workdir) { - var startInfo = new ProcessStartInfo(); + if (string.IsNullOrEmpty(workdir) || !Path.Exists(workdir)) + { + workdir = "."; + } - if (!string.IsNullOrEmpty(workdir) && Path.Exists(workdir)) - { - startInfo.WorkingDirectory = workdir; - } - else - { - startInfo.WorkingDirectory = "."; - } + var startInfo = new ProcessStartInfo(); + startInfo.WorkingDirectory = workdir; switch (Shell) { @@ -167,7 +164,7 @@ namespace SourceGit.Native var bash = Path.Combine(binDir, "bash.exe"); 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; } @@ -175,6 +172,7 @@ namespace SourceGit.Native break; case Models.Shell.PowerShell: startInfo.FileName = _powershellPath; + startInfo.Arguments = $"-WorkingDirectory \"{workdir}\" -Nologo"; break; case Models.Shell.CommandPrompt: startInfo.FileName = "cmd"; @@ -183,7 +181,7 @@ namespace SourceGit.Native startInfo.FileName = "wt"; break; default: - App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Bad shell configuration!"); + App.RaiseException(workdir, $"Bad shell configuration!"); return; }