Created
October 10, 2016 05:14
-
-
Save l04m33/83e66d17ae7eb713d7070d350ae1ff10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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