summaryrefslogblamecommitdiff
path: root/rofi-pass.sh
blob: 136646686db96e5a86a9977454b0c9c52a4fe7f6 (plain) (tree)






























                                                                    
#!/bin/sh
prefix=${PASSWORD_STORE_DIR:-~/.password-store}

get_passwords() {
	find -s "$prefix" -type f -name '*.gpg'
}

trim_prefix() {
	while read line
	do
		printf '%s\n' "${line##$prefix/}"
	done
}

trim_gpg() {
	while read line
	do
		printf '%s\n' "${line%%.gpg}"
	done
}

[ -z "$2" ] && get_passwords | trim_prefix | trim_gpg && exit 0

case "$1" in
	otp*)
		pass otp --clip "${2##totp:}" >/dev/null 2>&1 &
		;;
	pass*)
		pass show --clip "${2##password:}" >/dev/null 2>&1 &
		;;
esac