From 56e206ab74a25bf9ff2812d5328d085f0eb3196c Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Tue, 29 Sep 2015 19:49:49 +0100 Subject: [PATCH] Ensure a noop if we have an ssh-agent environment configured. --- .bashrc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.bashrc b/.bashrc index f87f7d0..467f2e6 100644 --- a/.bashrc +++ b/.bashrc @@ -88,14 +88,17 @@ function start_agent { /usr/bin/ssh-add ~/.ssh/scott_dsa } -# Source SSH settings, if applicable -if [ -f "${SSH_ENV}" ]; then - . "${SSH_ENV}" > /dev/null - pgrep ssh-agent | grep -E "^${SSH_AGENT_PID}" > /dev/null || { - start_agent - } -else - start_agent +# Check if we already have an agent running and sourced +if [ -z "${SSH_AUTH_SOCK}" ]; then + # Source SSH settings, if applicable + if [ -f "${SSH_ENV}" ]; then + . "${SSH_ENV}" > /dev/null + pgrep ssh-agent | grep -E "^${SSH_AGENT_PID}" > /dev/null || { + start_agent + } + else + start_agent + fi fi #--------------------------------------------------------------------------------