From b6f56ab7afe601c9fda4717a5300e5f15cf1a413 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Fri, 17 Mar 2017 19:16:11 -0700 Subject: [PATCH] Add gpg convenience script. --- bash/gpg-up.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 bash/gpg-up.sh diff --git a/bash/gpg-up.sh b/bash/gpg-up.sh new file mode 100644 index 0000000..8ce79f9 --- /dev/null +++ b/bash/gpg-up.sh @@ -0,0 +1,14 @@ +# This function ensures gpg commands will work properly, in the current shell. I have found it needful on +# OS X when using a smartcard and gpg-agent for ssh auth, in particular. +function gpg-up() { + while [[ $(ps axu | grep gpg-agent | grep -v grep | wc -l | tr -d ' ') -ne '0' ]]; do + pkill gpg-agent + sleep 1 + done + + gpg-agent --daemon + . ~/.gpg-agent-info + GPG_TTY=$(tty) + + export GPG_TTY GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID +}