This repository has been archived on 2022-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
prezto/modules/gpg-agent/init.zsh

47 lines
1015 B
Bash
Raw Normal View History

2012-01-31 23:37:51 -05:00
#
# Provides for an easier use of gpg-agent.
#
# Authors:
# Florian Walch <florian.walch@gmx.at>
# Sorin Ionescu <sorin.ionescu@gmail.com>
# neersighted <neersighted@myopera.com>
2012-01-31 23:37:51 -05:00
#
2012-07-23 15:00:44 -04:00
# Return if requirements are not found.
2011-08-30 23:16:15 -04:00
if (( ! $+commands[gpg-agent] )); then
2012-03-28 12:19:53 -04:00
return 1
2011-08-30 23:16:15 -04:00
fi
# Make sure to use the $GNUPGHOME first.
_gpg_env="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.env"
function _gpg-agent-start {
local ssh_support
zstyle -b ':prezto:module:gpg-agent' ssh-support 'ssh_support' \
|| ssh_support=''
gpg-agent \
--daemon \
${ssh_support:+'--enable-ssh-support'} \
--write-env-file "${_gpg_env}" > /dev/null
chmod 600 "${_gpg_env}"
source "${_gpg_env}" > /dev/null
}
2011-08-30 23:16:15 -04:00
# Source GPG agent settings, if applicable.
if [[ -s "${_gpg_env}" ]]; then
source "${_gpg_env}" > /dev/null
ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'gpg-agent' || {
_gpg-agent-start
}
else
_gpg-agent-start
fi
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
export GPG_TTY="$(tty)"