diff --git a/zlogin b/zlogin index a7d31bf..8d3c86e 100644 --- a/zlogin +++ b/zlogin @@ -77,16 +77,6 @@ if [ ${USER} != "root" ] && [ $(command -v startx) ]; then fi fi -# ssh-agent with fix socket path {{{ +# ssh-agent with fix socket path ## See load-ssh-agent function in ~/.zsh/zshrc load-ssh-agent -# }}} - -# GPG Agent {{{ -if [ -f $HOME/.gnupg/secring.gpg ]; then - # Keychain - ## Don't ask for gpg password, it will be asked at the first usage - keychain --noask --agents gpg - . $HOME/.keychain/$HOST-sh-gpg -fi -# }}} diff --git a/zshenv b/zshenv index 94779a9..a638077 100644 --- a/zshenv +++ b/zshenv @@ -108,3 +108,7 @@ SSH_AGENT_ENV="${HOME}/.ssh/socks/ssh_agent_env" ## ssh-keys path SSH_ED25519_KEY="${HOME}/.ssh/id_ed25519" SSH_RSA_KEY="${HOME}/.ssh/id_rsa" + +# GPG +GPG_PRIV_KEY="${HOME}/.gnupg/secring.gpg" +GPG_TEST_FILE="${HOME}/.password-store/test" diff --git a/zshrc b/zshrc index cae5c94..7ec9131 100644 --- a/zshrc +++ b/zshrc @@ -373,19 +373,24 @@ alias scpdev='scp -o UserKnownHostsFile=/dev/null' # }}} -## Keychain for GPG {{{ -function gpg() { - ## If keychain exists, run gpg from default $PATH as usual - if [ -f ~/.keychain/"${HOST}"-sh-gpg ]; then - command -p gpg ${*} - else ## Otherwise, reload keychain and run gpg - keychain --agents gpg - source ~/.keychain/"${HOST}"-sh-gpg - command -p gpg ${*} +# GPG {{{ +######### + +# Load gpg-agent {{{ +## This function can be used : +## 1. with aliases (git commit,…) +function load-gpg-agent() { + ## If a gpg key is available + if [ -f "${GPG_PRIV_KEY}" ]; then + ## Remove any previous test file + rm --force -- "${GPG_TEST_FILE}" + ## Run a gpg command on the test file + gpg --quiet --for-your-eyes-only --decrypt "${GPG_TEST_FILE}.gpg" > /dev/null fi } -## }}} +# }}} +# }}} # Taskwarrior {{{ ## Aliases