Skip to content

Instantly share code, notes, and snippets.

@ghostsquad
Created September 4, 2019 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghostsquad/3d9bdcc559eb132b365412d9a11df09e to your computer and use it in GitHub Desktop.
Save ghostsquad/3d9bdcc559eb132b365412d9a11df09e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
envfile="$HOME/.gnupg/gpg-agent.env"
if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --enable-ssh-support)"
fi
export GPG_AGENT_INFO # the env file does not contain the export statement
export SSH_AUTH_SOCK # enable gpg-agent for ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment