1
0
Fork 0
dotfiles/mutt/get-passwd

30 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Retrieves an account password
#
# Copyright (C) 2014 Mike Gerwitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##
# set up agent connection and pinentry CLI
export GPG_TTY="$(tty)"
test -r ~/.gnupg/.agent && . ~/.gnupg/.agent
# this will silently decrypt and retrieve the password if the agent is
# running (which is ideally the case so as not to screw with mutt's
# rendering)
gpg --batch --decrypt ~/.mutt/passwd.gpg 2>/dev/null \
| grep "^$1" \
| awk '{ print $2 }'