Add script to ensure ssh agent is running to bash

This commit is contained in:
Buddy Sandidge 2019-12-14 13:56:24 -08:00
parent 362c5f3682
commit ac60eb45ee
2 changed files with 15 additions and 0 deletions

14
bash/ensure-ssh-agent Normal file
View File

@ -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

1
bashrc
View File

@ -15,6 +15,7 @@ source-file ~/.bash/functions
source-file ~/.bash/path source-file ~/.bash/path
source-file ~/.bash/environment source-file ~/.bash/environment
source-file ~/.bash/prompt source-file ~/.bash/prompt
source-file ~/.bash/ensure-ssh-agent
source-file ~/opt/bash/env source-file ~/opt/bash/env
unset -f source-file unset -f source-file