-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypass
More file actions
executable file
·61 lines (50 loc) · 1.16 KB
/
Copy pathmypass
File metadata and controls
executable file
·61 lines (50 loc) · 1.16 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
shopt -s nullglob globstar
in_term() {
[[ -t 0 || -p /dev/stdin ]]
}
select_from () {
local a c cmd
cmd='command -v'
for a; do
case "$a" in
-c) cmd="$2"; 2 ;;
*) [[ $a = -* ]] && break 2 ;;
esac
shift
done
for c in "$@"; do
if $cmd "${c%% *}" &> /dev/null; then
echo "$c"
return 0
fi
done
return 1
}
declare generate
for a; do
case "$a" in
-g|--generate) generate=1 ;;
*) [[ $a = -* ]] && break 2 ;;
esac
shift
done
typeit() {
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
if in_term; then
password=$(printf '%s\n' "${password_files[@]}" | fzf --inline-info --cycle --ansi)
else
password=$(printf '%s\n' "${password_files[@]}" | dmenu -fn "$DMENU_FONT" -z)
fi
[[ -z $password ]] && exit
picker=$(select_from 'slop' 'xprop')
if in_term && [[ -n $picker ]]; then
$picker &> /dev/null
fi
read -r pass < <(pass show "$password")
printf '%s' "$pass" | xdotool type --clearmodifiers --file -
}
typeit