use dynamic ssh agent

This commit is contained in:
foosinn 2021-03-30 17:31:25 +02:00
parent a31009b178
commit 71d2575ea8

View file

@ -53,9 +53,19 @@ in {
export EDITOR=nvim
export STARSHIP_CONFIG=/etc/starship.toml
if [ -z "$SSH_AUTH_SOCK" ]; then
eval $(ssh-agent)
if [ -f ~/.ssh/agent.env ] ; then
. ~/.ssh/agent.env > /dev/null
if ! kill -0 "$SSH_AGENT_PID" > /dev/null 2>&1; then
echo "Stale agent file found. Spawning a new agent. "
eval `ssh-agent | tee ~/.ssh/agent.env`
ssh-add
fi
else
echo "Starting ssh-agent"
eval `ssh-agent | tee ~/.ssh/agent.env`
ssh-add
fi
set_win_title() {
echo -ne "\033]0;$USER@$HOSTNAME: $PWD\007"