Created
April 28, 2014 12:34
-
-
Save benjmin-r/11370468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Simple password management in ksh-compatible shell | |
## You'll need a unix-like system and a working GPG configuration | |
export GPG_KEY="" | |
function pwgrep() { | |
gpg --batch -q -d -r $GPG_KEY $HOME/.auth/pwdb.asc | grep $* | |
} | |
function pwcat() { | |
gpg --batch -q -d -r $GPG_KEY $HOME/.auth/pwdb.asc | |
} | |
function pwinit() { | |
mkdir -p $HOME/.auth | |
if [ ! -f $HOME/.auth/pwdb.asc ] ; then | |
echo -n | gpg -q --batch -a -e -r $GPG_KEY > $HOME/.auth/pwdb.asc | |
fi | |
} | |
function pwedit() { | |
[ -z $EDITOR ] && EDITOR=vi | |
file=`mktemp /tmp/pwedit.XXXXXX` | |
gpg -q -d --batch -r $GPG_KEY $HOME/.auth/pwdb.asc > $file && \ | |
$EDITOR $file && \ | |
gpg -q --batch -a -e -r $GPG_KEY $file && \ | |
mv ${file}.asc $HOME/.auth/pwdb.asc | |
rm -f $file ${file}.asc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment