From 2e64f7ed64306fb0a57d509d9724a7a698f71138 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Tue, 30 Apr 2013 22:53:56 -0400 Subject: [PATCH] [Fix #419] Rewrite module gpg-agent; rename it to gpg --- modules/README.md | 4 ++-- modules/gpg-agent/README.md | 25 -------------------- modules/gpg-agent/init.zsh | 46 ------------------------------------- modules/gpg/README.md | 16 +++++++++++++ modules/gpg/init.zsh | 31 +++++++++++++++++++++++++ runcoms/zpreztorc | 7 ------ 6 files changed, 49 insertions(+), 80 deletions(-) delete mode 100644 modules/gpg-agent/README.md delete mode 100644 modules/gpg-agent/init.zsh create mode 100644 modules/gpg/README.md create mode 100644 modules/gpg/init.zsh diff --git a/modules/README.md b/modules/README.md index 79a4725..16754fc 100644 --- a/modules/README.md +++ b/modules/README.md @@ -46,10 +46,10 @@ GNU Utility Provides for the interactive use of GNU utilities on non-GNU systems. -GPG-Agent +GPG --------- -Provides for an easier use of gpg-agent. +Provides for an easier use of GPG by setting up gpg-agent. Haskell ------- diff --git a/modules/gpg-agent/README.md b/modules/gpg-agent/README.md deleted file mode 100644 index 1b222d4..0000000 --- a/modules/gpg-agent/README.md +++ /dev/null @@ -1,25 +0,0 @@ -GPG-Agent -========= - -Provides for an easier use of [gpg-agent][1]. - -Settings --------- - -### SSH-Agent Protocol Emulation - -To enable SSH-Agent protocol emulation, add the following line to *zpreztorc*: - - zstyle ':prezto:module:gpg-agent' ssh-support 'yes' - -Authors -------- - -*The authors of this module should be contacted via the [issue tracker][2].* - - - [Florian Walch](https://github.com/fwalch) - - [Sorin Ionescu](https://github.com/sorin-ionescu) - -[1]: http://linux.die.net/man/1/gpg-agent -[2]: https://github.com/sorin-ionescu/prezto/issues - diff --git a/modules/gpg-agent/init.zsh b/modules/gpg-agent/init.zsh deleted file mode 100644 index 82bd9a2..0000000 --- a/modules/gpg-agent/init.zsh +++ /dev/null @@ -1,46 +0,0 @@ -# -# Provides for an easier use of gpg-agent. -# -# Authors: -# Florian Walch -# Sorin Ionescu -# neersighted -# - -# Return if requirements are not found. -if (( ! $+commands[gpg-agent] )); then - return 1 -fi - -# Make sure to use the $GNUPGHOME first. -_gpg_env="${GNUPGHOME:-$HOME/.gnupg}/gpg-agent.env" - -function _gpg-agent-start { - local ssh_support - - zstyle -b ':prezto:module:gpg-agent' ssh-support 'ssh_support' \ - || ssh_support='' - - gpg-agent \ - --daemon \ - ${ssh_support:+'--enable-ssh-support'} \ - --write-env-file "${_gpg_env}" > /dev/null - - chmod 600 "${_gpg_env}" - source "${_gpg_env}" > /dev/null -} - -# Source GPG agent settings, if applicable. -if [[ -s "${_gpg_env}" ]]; then - source "${_gpg_env}" > /dev/null - ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'gpg-agent' || { - _gpg-agent-start - } -else - _gpg-agent-start -fi - -export GPG_AGENT_INFO -export SSH_AUTH_SOCK -export SSH_AGENT_PID -export GPG_TTY="$(tty)" diff --git a/modules/gpg/README.md b/modules/gpg/README.md new file mode 100644 index 0000000..05db901 --- /dev/null +++ b/modules/gpg/README.md @@ -0,0 +1,16 @@ +GPG +=== + +Provides for an easier use of [GPG][1] by setting up [gpg-agent][2]. + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][3].* + + - [Sorin Ionescu](https://github.com/sorin-ionescu) + +[1]: http://www.gnupg.org +[2]: http://linux.die.net/man/1/gpg-agent +[3]: https://github.com/sorin-ionescu/prezto/issues + diff --git a/modules/gpg/init.zsh b/modules/gpg/init.zsh new file mode 100644 index 0000000..f175942 --- /dev/null +++ b/modules/gpg/init.zsh @@ -0,0 +1,31 @@ +# +# Provides for an easier use of GPG by setting up gpg-agent. +# +# Authors: +# Sorin Ionescu +# + +# Return if requirements are not found. +if (( ! $+commands[gpg-agent] )); then + return 1 +fi + +# Set the default path to the gpg-agent-info file. +_gpg_agent_info="$HOME/.gpg-agent-info" + +# Start gpg-agent if not started. +ps -U "$USER" -o ucomm | grep -q gpg-agent \ + || gpg-agent --daemon >! "$_gpg_agent_info" + +# Export environment variables. +export GPG_TTY="$(tty)" +source "$_gpg_agent_info" + +# Clean up. +unset _gpg_agent_info + +# Disable GUI prompts inside SSH. +if [[ -n "$SSH_CONNECTION" ]]; then + export PINENTRY_USER_DATA='USE_CURSES=1' +fi + diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index 932edc3..4fe15fc 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -94,13 +94,6 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Auto start a session when Zsh is launched. # zstyle ':prezto:module:screen' auto-start 'yes' -# -# GPG-Agent -# - -# Enable SSH-Agent protocol emulation. -# zstyle ':prezto:module:gpg-agent' ssh-support 'yes' - # # SSH-Agent #