From ac60eb45ee9376ffb099a2e5dbead29aa722f1e7 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Sat, 14 Dec 2019 13:56:24 -0800 Subject: [PATCH] Add script to ensure ssh agent is running to bash --- bash/ensure-ssh-agent | 14 ++++++++++++++ bashrc | 1 + 2 files changed, 15 insertions(+) create mode 100644 bash/ensure-ssh-agent diff --git a/bash/ensure-ssh-agent b/bash/ensure-ssh-agent new file mode 100644 index 0000000..e6fc430 --- /dev/null +++ b/bash/ensure-ssh-agent @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +ENVFILE=~/.bash/ssh-agent.env + +if [ -f $ENVFILE ] ; then + . $ENVFILE > /dev/null + if ! kill -0 $SSH_AGENT_PID > /dev/null 2>&1; then + eval $(ssh-agent | tee $ENVFILE) + ssh-add + fi +else + eval $(ssh-agent | tee $ENVFILE) + ssh-add +fi diff --git a/bashrc b/bashrc index 6bb87e2..56d94f9 100644 --- a/bashrc +++ b/bashrc @@ -15,6 +15,7 @@ source-file ~/.bash/functions source-file ~/.bash/path source-file ~/.bash/environment source-file ~/.bash/prompt +source-file ~/.bash/ensure-ssh-agent source-file ~/opt/bash/env unset -f source-file