From b8d581ff2a666d169c7dc404f813d424a9ecbed0 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 21 Jan 2013 17:35:59 -0800 Subject: [PATCH] Improve GPG agent startup. 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. --- modules/gpg-agent/init.zsh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/gpg-agent/init.zsh b/modules/gpg-agent/init.zsh index 6d010d28..82bd9a2e 100644 --- a/modules/gpg-agent/init.zsh +++ b/modules/gpg-agent/init.zsh @@ -4,6 +4,7 @@ # Authors: # Florian Walch # Sorin Ionescu +# neersighted # # Return if requirements are not found. @@ -11,7 +12,8 @@ if (( ! $+commands[gpg-agent] )); then return 1 fi -_gpg_env="$HOME/.gnupg/gpg-agent.env" +# Make sure to use the $GNUPGHOME first. +_gpg_env="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.env" function _gpg-agent-start { local ssh_support @@ -20,7 +22,8 @@ function _gpg-agent-start { || ssh_support='' gpg-agent \ - --daemon ${ssh_support:+'--enable-ssh-support'} + --daemon \ + ${ssh_support:+'--enable-ssh-support'} \ --write-env-file "${_gpg_env}" > /dev/null chmod 600 "${_gpg_env}" @@ -41,4 +44,3 @@ export GPG_AGENT_INFO export SSH_AUTH_SOCK export SSH_AGENT_PID export GPG_TTY="$(tty)" -