Created
October 10, 2016 10:29
Revisions
-
thinkbeforecoding created this gist
Oct 10, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ . $env:UserProfile\AppData\Local\GitHub\shell.ps1 Function Start-SSHAgent{ param( [Parameter(Mandatory=$false,ValueFromPipeline=$true)] [string]$socketfile="/tmp/.ssh-socket", # Used as input to ssh-agent, which expects POSIX format paths [Parameter(Mandatory=$false)] [string]$pidFile="$env:TEMP\.ssh-agent-pid" # Used as input to Out-File which expects Windows format paths ) $env:SSH_AUTH_SOCK=$socketfile $agent_is_running = Get-Process | ? { $_.ProcessName -like "ssh-agent*"} if($agent_is_running -eq $null){ rm $env:Temp\.ssh-socket -Force -ErrorAction SilentlyContinue $sshAgentOutput = ssh-agent -a $env:SSH_AUTH_SOCK $parse = Select-String -InputObject $sshAgentOutput -Pattern "(?m)SSH_AGENT_PID=(\d+)" $sshAgentPid = $parse.Matches[0].Groups[1].Value $sshAgentPid | Out-File $pidFile $env:SSH_AGENT_PID = $sshAgentPid } } #$r = ssh-agent -s #[regex]::Matches($r,"SSH_AUTH_SOCK=([^;]+);") | % { $env:SSH_AUTH_SOCK = $_.Groups[1] } #[regex]::Matches($r,"SSH_AGENT_PID=(\d+);") | % { $env:SSH_AGENT_PID = $_.Groups[1] } Start-SSHAgent ssh-add $env:UserProfile\.ssh\github_rsa