summaryrefslogtreecommitdiff
path: root/rofi-pass.sh
blob: 136646686db96e5a86a9977454b0c9c52a4fe7f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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