dotfiles/.bin/OLD/pwadd

33 lines
555 B
Plaintext
Raw Normal View History

2023-02-22 08:31:38 +01:00
#!/bin/sh
_ask() {
# $1 question
# $2 default value
if [ -z $1 ]; then
printf "$1: "
else
printf "$1 [$2]: "
fi
}
_ask "Url" "$1"
read url
[ -z $url ] && url="$1"
_ask "User" "$2"
read user
[ -z $user ] && user="$2"
if [ -z $user ] || [ -z $url ]; then
print "User and URL must be set."
exit 1
fi
PW="$(pwgen -y --remove-chars=\~\`\"\'{}\(\)\[\]\*:/.\;\|,\<\> 24)
User: $user"
printf '%s\n' "$PW" | pass insert -fm Internet/$url 1> /dev/null
pass Internet/$url | head -1 | xclip
print "Password copied."