mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
feature: try to read PATH
from zsh
This commit is contained in:
parent
1a4055ee97
commit
a232f50755
2 changed files with 26 additions and 9 deletions
|
@ -195,15 +195,6 @@ namespace SourceGit.Commands
|
||||||
if (OperatingSystem.IsLinux())
|
if (OperatingSystem.IsLinux())
|
||||||
start.Environment.Add("LANG", "en_US.UTF-8");
|
start.Environment.Add("LANG", "en_US.UTF-8");
|
||||||
|
|
||||||
// Fix sometimes `LSEnvironment` not working on macOS
|
|
||||||
if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
if (start.Environment.TryGetValue("PATH", out var path))
|
|
||||||
start.Environment.Add("PATH", $"/opt/homebrew/bin:/opt/homebrew/sbin:{path}");
|
|
||||||
else
|
|
||||||
start.Environment.Add("PATH", "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force using this app as git editor.
|
// Force using this app as git editor.
|
||||||
switch (Editor)
|
switch (Editor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
|
||||||
|
@ -17,6 +18,31 @@ namespace SourceGit.Native
|
||||||
{
|
{
|
||||||
DisableDefaultApplicationMenuItems = true,
|
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()
|
public string FindGitExecutable()
|
||||||
|
|
Loading…
Reference in a new issue