diff options
| author | Robert Günzler <r@gnzler.io> | 2026-04-08 13:18:14 +0900 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-04-08 13:18:14 +0900 |
| commit | b61b58ce2c1371d6f904f108fa7feed3abfbe5c7 (patch) | |
| tree | 008a5cf54ecbfffb97ddac30e44c8ab224395ab0 /bin/pasm | |
| parent | d4620f3ac119263fee90bd819eadaf84fc8d50b7 (diff) | |
*
Automated-commit-by: dots Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bin/pasm')
| -rwxr-xr-x | bin/pasm | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/bin/pasm b/bin/pasm new file mode 100755 index 0000000..7555167 --- /dev/null +++ b/bin/pasm @@ -0,0 +1,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 |