Skip to content

Instantly share code, notes, and snippets.

@johnweldon
Created December 20, 2011 00:43
Show Gist options
  • Select an option

  • Save johnweldon/1499642 to your computer and use it in GitHub Desktop.

Select an option

Save johnweldon/1499642 to your computer and use it in GitHub Desktop.
powershell script to start the ssh-agent
$ gcm start-sshagent | fl
Name : start-sshagent
CommandType : Function
Definition :
if($env:SSH_AGENT_PID) { echo "ssh-agent running"; return }
$private:gp = get-gitbinpath
if($private:gp) {
$private:out = & (join-path $private:gp "ssh-agent")
$private:out | ?{$_.contains("=")} | %{
$private:cur = $_.split(";")[0]
$private:pair = $private:cur.split("=")
$private:cmd = ('$env:{0}="{1}"' -f $private:pair)
invoke-expression $private:cmd
}
write-warning "Use exit to leave shell"
register-engineevent powershell.exiting -action {
ps -Id $env:SSH_AGENT_PID -ErrorAction SilentlyContinue | stop-process
} | out-null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment