Browse Source

[Fix #419] Rewrite module gpg-agent; rename it to gpg

master
Sorin Ionescu 12 years ago
parent
commit
2e64f7ed64
  1. 4
      modules/README.md
  2. 25
      modules/gpg-agent/README.md
  3. 46
      modules/gpg-agent/init.zsh
  4. 16
      modules/gpg/README.md
  5. 31
      modules/gpg/init.zsh
  6. 7
      runcoms/zpreztorc

4
modules/README.md

@ -46,10 +46,10 @@ GNU Utility
Provides for the interactive use of GNU utilities on non-GNU systems. 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 Haskell
------- -------

25
modules/gpg-agent/README.md

@ -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

46
modules/gpg-agent/init.zsh

@ -1,46 +0,0 @@
#
# Provides for an easier use of gpg-agent.
#
# Authors:
# Florian Walch <florian.walch@gmx.at>
# Sorin Ionescu <sorin.ionescu@gmail.com>
# neersighted <neersighted@myopera.com>
#
# 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)"

16
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

31
modules/gpg/init.zsh

@ -0,0 +1,31 @@
#
# Provides for an easier use of GPG by setting up gpg-agent.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# 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

7
runcoms/zpreztorc

@ -94,13 +94,6 @@ zstyle ':prezto:module:prompt' theme 'sorin'
# Auto start a session when Zsh is launched. # Auto start a session when Zsh is launched.
# zstyle ':prezto:module:screen' auto-start 'yes' # zstyle ':prezto:module:screen' auto-start 'yes'
#
# GPG-Agent
#
# Enable SSH-Agent protocol emulation.
# zstyle ':prezto:module:gpg-agent' ssh-support 'yes'
# #
# SSH-Agent # SSH-Agent
# #

Loading…
Cancel
Save