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 +}