diff --git a/plugins/gpg-agent/README.md b/plugins/gpg-agent/README.md index 8eeb94f92..cf851f5ad 100644 --- a/plugins/gpg-agent/README.md +++ b/plugins/gpg-agent/README.md @@ -1,6 +1,11 @@ # gpg-agent -Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running. +Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running and fixes some common issues. + +Issues fixed are: + +* The `GPG_TTY` environment variable being set incorrectly or not set at all. +* SSH agent support being broken when `enable-ssh-support` is enabled. To use it, add `gpg-agent` to the plugins array of your zshrc file: diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh index 1f4be20b0..b1cbb62d0 100644 --- a/plugins/gpg-agent/gpg-agent.plugin.zsh +++ b/plugins/gpg-agent/gpg-agent.plugin.zsh @@ -1,8 +1,10 @@ -export GPG_TTY=$TTY +# Launch gpg-agent ahead of time +gpgconf --launch gpg-agent # Fix for passphrase prompt on the correct tty # See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport function _gpg-agent_update-tty_preexec { + export GPG_TTY="${TTY}" gpg-connect-agent updatestartuptty /bye &>/dev/null } autoload -U add-zsh-hook