From: Amin Bandali Date: Sun, 14 Apr 2019 20:52:36 +0000 (-0400) Subject: bash: start ssh-agent if not running X-Git-Url: https://git.shemshak.org/gitweb.cgi/~bandali/configs/commitdiff_plain/6e39e3a24b092de97e70563e66ff08a4b8dd1674 bash: start ssh-agent if not running --- diff --git a/.bashrc b/.bashrc index f4fa270..309cbd1 100644 --- a/.bashrc +++ b/.bashrc @@ -45,3 +45,10 @@ a_prompt() { printf $cwd } PS1="\u@\h \$(a_prompt)> " + +if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent > ~/.ssh-agent-thing +fi +if [[ ! "$SSH_AUTH_SOCK" ]]; then + eval "$(<~/.ssh-agent-thing)" +fi