gpg-agent.plugin.zsh 532 Bytes
Newer Older
1
2
3
# Enable gpg-agent if it is not running-
# --use-standard-socket will work from version 2 upwards

4
AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
5

6
7
if [[ ! -S $AGENT_SOCK ]]; then
  gpg-agent --daemon --use-standard-socket &>/dev/null
8
fi
9
export GPG_TTY=$TTY
Florian Walch's avatar
Florian Walch committed
10

11
# Set SSH to use gpg-agent if it's enabled
12
13
14
GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then
  export SSH_AUTH_SOCK="$AGENT_SOCK.ssh"
15
  unset SSH_AGENT_PID
16
fi