From b61b58ce2c1371d6f904f108fa7feed3abfbe5c7 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 8 Apr 2026 13:18:14 +0900 Subject: * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated-commit-by: dots Signed-off-by: Robert Günzler --- bin/pasm | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 bin/pasm (limited to 'bin/pasm') 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 -- cgit 1.4.1