blob: 75551670e285d132c55d33e721212dd2d949054f (
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
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
62
63
64
65
66
67
68
69
70
71
|
#!/bin/sh
# local is well supported
# shellcheck disable=3043
set -eux
# shellcheck disable=2034
description="rbw-based password manager"
FUZL_PROMPT=pasm
FUZL_ICON=
. libfuzl.sh
main() {
rbw unlocked 2>/dev/null ||
rbw unlock || exit 1
local eid
eid=$(rbw_select_entry)
fuzl_action_add "copy" "" "copy username/password"
rbw_has_totp "$eid" && fuzl_action_add "totp" "" "copy totp code"
fuzl_action_add "url" "" "copy url"
fuzl_action_menu "$eid" || exit 1
}
#
# helpers
#
rbw_select_entry() {
rbw list --raw |
jq -r '.[] | select(.type=="Login") | [.id,.name,.user,(.uris[0]//"-")]|join("%")' |
awk -F% '{print $1 "\t" ($2 " →") "\t" (" " $3) "\t" (" " $4)}' |
fuzl_menu $FUZL_MENU_FILTER --with-nth='{2} {3..}' --accept-nth=1 -w 80
}
rbw_has_totp() {
local eid=${1:?missing eid}
# can't use fuzl_try here because we need the exit status
rbw get -l "$eid" | grep -q totp
}
rbw_entry() {
local eid=${1:?missing eid}
fuzl_try -- rbw get --raw "$eid" | jq -r '.name'
}
#
# actions
#
pasm_copy() {
local eid=${1:?missing eid}
fuzl_try -- rbw get -f password "$eid" | wl-copy -n
fuzl_try -- rbw get -f username "$eid" | wl-copy -p -n
fuzl_notification "$(rbw_entry "$eid")" "copied to clipboard"
}
pasm_totp() {
local eid=${1:?missing eid}
fuzl_try -- rbw totp "$eid" | wl-copy -n
fuzl_notification "$(rbw_entry "$eid")" "copied totp to clipboard"
}
pasm_url() {
local eid=${1:?missing eid}
fuzl_try -- rbw get -f uris "$eid" | head -n1 | wl-copy -n
fuzl_notification "$(rbw_entry "$eid")" "copied url to clipboard"
}
main
|