33 lines
555 B
Bash
Executable File
33 lines
555 B
Bash
Executable File
#!/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."
|