Skip to content

Instantly share code, notes, and snippets.

@l04m33
Created October 10, 2016 05:14
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 l04m33/83e66d17ae7eb713d7070d350ae1ff10 to your computer and use it in GitHub Desktop.
Save l04m33/83e66d17ae7eb713d7070d350ae1ff10 to your computer and use it in GitHub Desktop.
local GPG_AGENT_BIN=/usr/bin/gpg-agent
local GPG_AGENT_ENV="$HOME/.gnupg/gpg-agent.env"
local GPG_CONNECT_AGENT_ERR_MSG="gpg-connect-agent: no gpg-agent running in this session"
function start_agent_withssh {
${GPG_AGENT_BIN} --quiet --enable-ssh-support --daemon 2> /dev/null > "${GPG_AGENT_ENV}"
chmod 600 "${GPG_AGENT_ENV}"
. "${GPG_AGENT_ENV}" > /dev/null
}
if [[ "$(gpg-connect-agent --no-autostart --quiet /bye 2>&1)" == "$GPG_CONNECT_AGENT_ERR_MSG" ]]; then
start_agent_withssh
elif [[ -f "${GPG_AGENT_ENV}" ]]; then
. "${GPG_AGENT_ENV}" > /dev/null
fi
GPG_TTY=$(tty)
export GPG_TTY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment