Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c922648

Browse files
authored
Merge pull request #235 from shiena/fix-mac-terminal
Fix script for opening terminal on mac
2 parents 793f493 + 4efc0fe commit c922648

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/GitHub.Api/OutputProcessors/ProcessManager.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,32 @@ public void RunCommandLineWindow(NPath workingDirectory)
7171
if (environment.IsWindows)
7272
{
7373
startInfo.FileName = "cmd";
74+
gitEnvironment.Configure(startInfo, workingDirectory);
7475
}
7576
else if (environment.IsMac)
7677
{
7778
// we need to create a temp bash script to set up the environment properly, because
7879
// osx terminal app doesn't inherit the PATH env var and there's no way to pass it in
7980

8081
var envVarFile = NPath.GetTempFilename();
81-
environment.FileSystem.WriteAllLines(envVarFile, new string[] { "cd $GHU_WORKINGDIR", "PATH=$GHU_FULLPATH:$PATH /bin/bash" });
82-
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
8382
startInfo.FileName = "open";
8483
startInfo.Arguments = $"-a Terminal {envVarFile}";
84+
gitEnvironment.Configure(startInfo, workingDirectory);
85+
86+
var envVars = startInfo.EnvironmentVariables;
87+
var scriptContents = new[] {
88+
$"cd {envVars["GHU_WORKINGDIR"]}",
89+
$"PATH={envVars["GHU_FULLPATH"]}:$PATH /bin/bash"
90+
};
91+
environment.FileSystem.WriteAllLines(envVarFile, scriptContents);
92+
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
8593
}
8694
else
8795
{
8896
startInfo.FileName = "sh";
97+
gitEnvironment.Configure(startInfo, workingDirectory);
8998
}
9099

91-
gitEnvironment.Configure(startInfo, workingDirectory);
92100
Process.Start(startInfo);
93101
}
94102

0 commit comments

Comments
 (0)