scre.git
prawn.sh
#!/bin/sh
# prawn - password manager
# Copyright (C) 2022-2023 ArcNyxx <me@arcnyxx.net>
# see LICENCE file for licensing information
die () { echo "$1" ; exit 1 ; }
[ -f "$PRAWN" ] || die 'prawn: $PRAWN file does not exist'
READ="`age -d "$PRAWN" 2>/dev/null`"
[ $? -eq 0 ] || die 'prawn: unable to read $PRAWN file'
case "$1" in
-a) echo 'prawn: enter site, user, and pass: '
read -r SITE ; read -r USER ; read -r PASS
{ echo "$READ" ; echo "$SITE $USER $PASS" ; } | sort -u \
| column -t | age -e -p >"$PRAWN" ;;
-r) echo 'prawn: enter site'
read -r SITE
[ `echo "$READ" | grep -c "^$SITE"` = 1 ] \
|| die 'prawn: more than one line selected'
echo "$READ" | grep -v "^$SITE" | sort -u \
| column -t | age -e -p >"$PRAWN" ;;
*) echo "$READ" ;;
esac