diff options
| author | Xiao Pan <xyz@flylightning.xyz> | 2024-08-14 22:45:01 -0700 | 
|---|---|---|
| committer | Xiao Pan <xyz@flylightning.xyz> | 2024-08-14 22:45:01 -0700 | 
| commit | 461637a7ad2cba3c316da4fcebd5d6bc447032eb (patch) | |
| tree | e0e5d7fa9f70af23817b230bc1da1a941c2c6105 /sh/pme | |
| parent | 0b66a7b7e692e8dd583eb418847c698f47f08fbc (diff) | |
pme output username
Diffstat (limited to 'sh/pme')
| -rwxr-xr-x | sh/pme | 29 | 
1 files changed, 23 insertions, 6 deletions
| @@ -1,15 +1,32 @@  #!/bin/sh  # my Pass MEnu +otp= +user= +while getopts ou opt; do +	case $opt in +		o) otp=1;; +		u) user=1;; +		\?) exit 1;; +	esac +done +  find "$HOME/.password-store/" \( -type f -o -type l \) -name '*.gpg' \  	| sed "s#$HOME/\.password-store/\(.*\)\.gpg\$#\1#" \  	| dmenu -i -p 'pass' \  	| { -		case "$1" in -			# `{ IFS= read -r p; printf '%s\r' "$p";}` is modified from https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu#n34 GPL-2.0-or-later code -			'') xargs pass | { IFS= read -r p; printf '%s\r' "$p";};; -			'-o') xargs pass otp | tr '\n' '\r';; -			*) exit 1;; -		esac +		if [ "$otp" ]; then +			xargs pass otp | tr '\n' '\r' +		else +			xargs pass | { +				if [ "$user" ]; then +					# https://www.gnu.org/software/gawk/manual/html_node/Case_002dsensitivity.html +					awk 'tolower($1) ~ /^(user|username):$/ {printf $2}' +				else +					# modified from https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu#n34 GPL-2.0-or-later code +					IFS= read -r p; printf '%s\r' "$p" +				fi +			} +		fi  	} \  	| xdotool type --clearmodifiers --file - | 
