From 6cb16f170a2e6afd2295295dcf371ab453f05a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 10 Mar 2015 13:59:33 +0800 Subject: [PATCH] gpg agent --- bash/bashrc/rbashrc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc index fa3a4a7..df02650 100644 --- a/bash/bashrc/rbashrc +++ b/bash/bashrc/rbashrc @@ -61,6 +61,25 @@ if ! shopt -oq posix; then fi fi +if [ -x "/usr/bin/gpg-agent" ]; then + GPG_ENV="$HOME/.gnupg/environment" + + function __start_agent { + gpg-agent --daemon > "${GPG_ENV}" + chmod 600 "${GPG_ENV}" + . "${GPG_ENV}" > /dev/null + } + + if [ -f "${GPG_ENV}" ]; then + . "${GPG_ENV}" > /dev/null + + gpg-agent > /dev/null 2>&1 + [ "$?" -ne 0 ] && { __start_agent; } + else + __start_agent; + fi +fi + BASHL_UUID="" export BASH_SDIR=/tmp/$BASHL_UUID [ ! -d "$BASH_SDIR" ] && mkdir "$BASH_SDIR"