gpg-agent.plugin.zsh
687 bytes
1export GPG_TTY=$TTY
2
3# Fix for passphrase prompt on the correct tty
4# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
5function _gpg-agent_update-tty_preexec {
6 gpg-connect-agent updatestartuptty /bye &>/dev/null
7}
8autoload -U add-zsh-hook
9add-zsh-hook preexec _gpg-agent_update-tty_preexec
10
11# If enable-ssh-support is set, fix ssh agent integration
12if [[ $(gpgconf --list-options gpg-agent 2>/dev/null | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
13 unset SSH_AGENT_PID
14 if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
15 export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
16 fi
17fi