Skip to content

Commit

Permalink
Output correct commands for each terminal
Browse files Browse the repository at this point in the history
Will output variable commands for PowerShell when the program is run
from PowerShell, will output Batch script syntax otherwise.
  • Loading branch information
RaeesBhatti committed Oct 23, 2016
1 parent 689dc93 commit 94e708e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ static void runAgent()
try
{
SSHAgent.Start();

Process parent = FindParent.ParentProcess(Process.GetCurrentProcess());

while (!SSHAgent.StandardOutput.EndOfStream)
{
var line = SSHAgent.StandardOutput.ReadLine();
Expand All @@ -126,15 +129,20 @@ static void runAgent()
{
AgentSock = command[1];
Environment.SetEnvironmentVariable(SSH_AUTH_SOCK, command[1], EnvironmentVariableTarget.User);
Console.WriteLine("set " + SSH_AUTH_SOCK + "=" + command[1]);
Console.WriteLine(
(parent.ProcessName == "powershell" ? "$env:" : "set ") + SSH_AUTH_SOCK + "=\"" + command[1] + "\";");
}
else if (command[0] == SSH_AGENT_PID && command.Length > 1)
{
AgentPID = command[1];
Environment.SetEnvironmentVariable(SSH_AGENT_PID, command[1], EnvironmentVariableTarget.User);
Console.WriteLine("set " + SSH_AGENT_PID + "=" + command[1]);
Console.WriteLine(
(parent.ProcessName == "powershell" ? "$env:" : "set ") + SSH_AGENT_PID + "=\"" + command[1] + "\";");
}
}
Console.WriteLine((parent.ProcessName == "powershell" ? "# " : "rem ") +
"Your environment has been configured. " +
"Run these commands to configure current terminal.");
}
catch (Exception e)
{
Expand Down

0 comments on commit 94e708e

Please sign in to comment.