From b9c99567ccd2276b86149ea0aee4325148487854 Mon Sep 17 00:00:00 2001 From: James Blair Date: Sun, 1 Mar 2020 08:05:19 +1300 Subject: [PATCH] Improved ssh-agent handling. --- .bashrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index 21d3efc..ad8ef60 100644 --- a/.bashrc +++ b/.bashrc @@ -62,8 +62,14 @@ color_my_prompt # Start from home folder cd ~/ -# Start ssh-agent -eval `ssh-agent` +# Configure ssh-agent +if [ -z "$(pgrep ssh-agent)" ]; then + rm -rf /tmp/ssh-* + eval $(ssh-agent -s) > /dev/null +else + export SSH_AGENT_PID=$(pgrep ssh-agent) + export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name agent.*) +fi # Remove bitwarden sessions older than a day if [[ $(find ~/.bw_session -mtime +1 -print) ]]; then rm ~/.bw_session; fi