mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-30 22:01:10 +08:00
feature: try to read PATH from zsh
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user