all repos — nixfiles @ e02cc4654d04b7efd5232c23c26a96aff2997b0c

System and user configuration, managed by nix and home-manager

zsh: Use gpg-agent instead of envoy
Alan Pearce alan@alanpearce.co.uk
Sun, 21 Jun 2015 11:28:53 +0200
commit

e02cc4654d04b7efd5232c23c26a96aff2997b0c

parent

b739f3f4f0a51f0656519a58c52c18909f73e46a

1 files changed, 9 insertions(+), 3 deletions(-)

jump to
M tag-zsh/config/zsh/zshenvtag-zsh/config/zsh/zshenv
@@ -66,8 +66,14 @@ then 	eval "$(direnv hook zsh)"
 fi
 
-if [[ $os == gnu && ! -S $SSH_AUTH_SOCK && -s $commands[envoy] ]]
+if [[ -s $commands[gpg-agent ]]]
 then
-	envoy -t gpg-agent
-	eval $(envoy -p)
+	envfile="$HOME/.gnupg/gpg-agent.env"
+	if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
+		eval "$(cat "$envfile")"
+	else
+		eval "$(gpg-agent --daemon --enable-ssh-support --write-env-file "$envfile")"
+	fi
+	export GPG_AGENT_INFO  # the env file does not contain the export statement
+	export SSH_AUTH_SOCK   # enable gpg-agent for ssh
 fi