]>
git.rmz.io Git - dotfiles.git/blob - zsh/lib/gpg.zsh
2 # Provides for an easier use of GPG by setting up gpg-agent.
5 # Sorin Ionescu <sorin.ionescu@gmail.com>
8 # Set the default paths to gpg-agent files.
9 _gpg_agent_conf
="$XDG_CONFIG_HOME/gnupg/gpg-agent.conf"
10 _gpg_agent_env
="$XDG_CACHE_HOME/gpg-agent-info"
12 # Return if requirements are not found.
13 if [[ ! -r "$_gpg_agent_conf" ]]; then
15 unset _gpg_agent_
{conf
,env
}
19 # Start gpg-agent if not started.
20 if ! ps
-U "$USER" -o ucomm
| grep -q gpg
-agent; then
21 eval "$(gpg-agent --daemon --write-env-file "$_gpg_agent_env")"
23 # Export environment variables.
24 source "$_gpg_agent_env" 2> /dev
/null
27 # Inform gpg-agent of the current TTY for user prompts.
28 export GPG_TTY
="$(tty)"
31 unset _gpg_agent_
{conf
,env
}
33 # Disable GUI prompts inside SSH.
34 if [[ -n "$SSH_CONNECTION" ]]; then
35 export PINENTRY_USER_DATA
='USE_CURSES=1'