-
Notifications
You must be signed in to change notification settings - Fork 0
/
passmenu.sh
executable file
·32 lines (25 loc) · 717 Bytes
/
passmenu.sh
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
32
#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
if [[ $typeit -eq 1 ]]; then
prompt='Type: '
else
prompt='Show: '
fi
password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@" -p "${prompt}")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
pwd=$(pass show "$password" 2>/dev/null)
choosen=$(printf '%s\n' "${pwd}" | dmenu -p "Choose: ")
printf '%s\n' $choosen
else
xdotool - <<<"type --clearmodifiers -- $(pass show "$password" | head -n 1)"
fi