|
@@ -3,6 +3,7 @@
|
|
|
multi=false
|
|
|
clipboard=false
|
|
|
type=false
|
|
|
+add=false
|
|
|
file=""
|
|
|
dir=""
|
|
|
|
|
@@ -42,12 +43,16 @@ if [ -z "$dmenu" ]; then
|
|
|
fi
|
|
|
|
|
|
|
|
|
-usage="$(printf "USAGE:\nneopassmenu [OPTS] [Pass Entry]\n\nOptions:\n-c\t\tCopy to clipboard instead of printing to stdout\n-t\t\tSimulate typing instead of printing to stdout\n-m\t\tSelect a specific line from a multiline file\n-h\\t\tPrint usage information\n\nCONFIGURATION:\nEnvironement variables:\nDMENU_COMMAND\tSpecify dmenu command (default: dmenu)")"
|
|
|
+usage="$(printf "USAGE:\nneopassmenu [OPTS] [Pass Entry]\n\nOptions:\n-a\t\tGenerate or modify a password\n-c\t\tCopy to clipboard instead of printing to stdout\n-t\t\tSimulate typing instead of printing to stdout\n-m\t\tSelect a specific line from a multiline file\n-h\\t\tPrint usage information\n\nCONFIGURATION:\nEnvironement variables:\nDMENU_COMMAND\tSpecify dmenu command (default: dmenu)")"
|
|
|
|
|
|
cd "${PASSWORD_STORE_DIR:-"$HOME/.password-store"}" || exit 2
|
|
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
case "$1" in
|
|
|
+ -a)
|
|
|
+ add=true
|
|
|
+ shift
|
|
|
+ ;;
|
|
|
-c)
|
|
|
clipboard=true
|
|
|
type=false
|
|
@@ -100,7 +105,7 @@ if [ -z "$file" ]; then
|
|
|
fi
|
|
|
elif [ -d "$newdir" ]; then
|
|
|
dir="$newdir"
|
|
|
- elif [ -f "$newdir" ] || [ -f "${newdir}.gpg" ]; then
|
|
|
+ elif [ -f "$newdir" ] || [ -f "${newdir}.gpg" ] || "$add"; then
|
|
|
file="$newdir"
|
|
|
break
|
|
|
else
|
|
@@ -109,16 +114,27 @@ if [ -z "$file" ]; then
|
|
|
done
|
|
|
fi
|
|
|
|
|
|
+if "$add"; then
|
|
|
+ if [ -f "${file}.gpg" ]; then
|
|
|
+ pass "$file" > /tmp/pass.txt
|
|
|
+ fi
|
|
|
+ printf "\n\n%s" "$(dd count=2 if=/dev/random of=/dev/stdout 2>/dev/null ibs=512 obs=512 | uuencode -m /dev/stdout | tail -n +2 | tr -d '\n')" >> /tmp/pass.txt
|
|
|
+ fileopener /tmp/pass.txt
|
|
|
+ save="$(printf "yes\nno" | $dmenu -p "Save changes? ")"
|
|
|
+ if [ "$save" = "yes" ]; then
|
|
|
+ cat /tmp/pass.txt || exit 1 | pass add -m -f "$file"
|
|
|
+ exit 0
|
|
|
+ fi
|
|
|
+ rm /tmp/pass.txt
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
if ! [ -f "$file" ] && ! [ -f "${file}.gpg" ]; then
|
|
|
exit 127
|
|
|
fi
|
|
|
|
|
|
if $clipboard && ! $multi; then
|
|
|
- if $x11; then
|
|
|
- printf "%s" "$(pass "$file")" | xclip -selection clipboard -i
|
|
|
- else
|
|
|
- echo "pass $file" | wl-copy --trim-newline
|
|
|
- fi
|
|
|
+ printf "%s" "$(pass "$file")" | cb copy
|
|
|
exit 0
|
|
|
elif $type && ! $multi; then
|
|
|
if $x11; then
|
|
@@ -152,11 +168,7 @@ password="$(echo "$password_lines" | sed '{ h; s/^.$//; s/^..//; s/./*/g; x; s/^
|
|
|
password="$(echo "$password_lines" | grep -xE "$(echo "$password" | sed 'y/*/./' )")"
|
|
|
|
|
|
if "$clipboard"; then
|
|
|
- if $x11; then
|
|
|
- printf "%s" "$password" | xclip -selection clipboard -i
|
|
|
- else
|
|
|
- printf "%s" "$password" | wl-copy --trim-newline
|
|
|
- fi
|
|
|
+ printf "%s" "$password" | cb copy
|
|
|
exit 0
|
|
|
elif "$type"; then
|
|
|
if $x11; then
|