feature: try to read PATH from zsh

This commit is contained in:
leo 2024-10-14 16:58:29 +08:00
parent 1a4055ee97
commit a232f50755
No known key found for this signature in database
2 changed files with 26 additions and 9 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.Versioning;
using System.Text;
using Avalonia;
@ -17,6 +18,31 @@ namespace SourceGit.Native
{
DisableDefaultApplicationMenuItems = true,
});
{
var startInfo = new ProcessStartInfo();
startInfo.FileName = "zsh";
startInfo.Arguments = "--login -c \"echo $PATH\"";
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.StandardOutputEncoding = Encoding.UTF8;
try
{
var proc = new Process() { StartInfo = startInfo };
proc.Start();
var pathData = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
if (proc.ExitCode == 0)
Environment.SetEnvironmentVariable("PATH", pathData);
proc.Close();
}
catch
{
// Ignore error.
}
}
}
public string FindGitExecutable()