Skip to content
Snippets Groups Projects
Commit 4efc0fe7 authored by Mitsuhiro Koga's avatar Mitsuhiro Koga
Browse files

Fix script for opening terminal on mac

Terminal.app does not inherit environment variables.
Therefore, expand environmet variables in the script.
parent 793f4930
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,7 @@ namespace GitHub.Unity
if (environment.IsWindows)
{
startInfo.FileName = "cmd";
gitEnvironment.Configure(startInfo, workingDirectory);
}
else if (environment.IsMac)
{
......@@ -78,17 +79,24 @@ namespace GitHub.Unity
// osx terminal app doesn't inherit the PATH env var and there's no way to pass it in
var envVarFile = NPath.GetTempFilename();
environment.FileSystem.WriteAllLines(envVarFile, new string[] { "cd $GHU_WORKINGDIR", "PATH=$GHU_FULLPATH:$PATH /bin/bash" });
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
startInfo.FileName = "open";
startInfo.Arguments = $"-a Terminal {envVarFile}";
gitEnvironment.Configure(startInfo, workingDirectory);
var envVars = startInfo.EnvironmentVariables;
var scriptContents = new[] {
$"cd {envVars["GHU_WORKINGDIR"]}",
$"PATH={envVars["GHU_FULLPATH"]}:$PATH /bin/bash"
};
environment.FileSystem.WriteAllLines(envVarFile, scriptContents);
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
}
else
{
startInfo.FileName = "sh";
gitEnvironment.Configure(startInfo, workingDirectory);
}
gitEnvironment.Configure(startInfo, workingDirectory);
Process.Start(startInfo);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment