This will prevent the ssh-agent from being started multiple times when using git for windows.
Will also work on linux.
function start_ssh_agent() { | |
local SSH_AGENT=$(which ssh-agent 2>/dev/null) | |
if [ -z "${SSH_AGENT}" ]; then | |
return 1 | |
fi | |
SSH_AUTH_SOCK=~/.ssh/ssh-agent.sock | |
SSH_AGENT_PID=$(ps | grep ssh-agent | tr -s ' ' | cut -f 2 -d ' ') | |
if [ -z "${SSH_AGENT_PID}" ]; then | |
eval $("${SSH_AGENT}" -a "${SSH_AUTH_SOCK}" 2>/dev/null | grep -v "echo") | |
fi | |
export SSH_AUTH_SOCK SSH_AGENT_PID | |
} | |
start_ssh_agent |