forked from sorin-ionescu/prezto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the value of $GNUPGHOME, to facilitate moving GPG's home. This lets users who keep their GPG keyring on external devices or alternate folders use the gpg-agent autostarting, even if $HOME/.gnupg does not exist.
- Loading branch information
neersighted
authored and
Adam Walz
committed
Jul 2, 2013
1 parent
b7f0853
commit f137152
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# Provides for an easier use of gpg-agent. | ||
# | ||
# Authors: | ||
# Florian Walch <[email protected]> | ||
# Sorin Ionescu <[email protected]> | ||
# neersighted <[email protected]> | ||
# | ||
|
||
# Return if requirements are not found. | ||
if (( ! $+commands[gpg-agent] )); then | ||
return 1 | ||
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 | ||
} | ||
|
||
# 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)" |