From 0f0de37ea99129ca6a22aae4e6e56787744d0355 Mon Sep 17 00:00:00 2001 From: hermes-bot Date: Tue, 28 Jul 2026 17:08:46 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20add=20bwp/bwc/bwu=20=E2=80=94=20rbw=20+?= =?UTF-8?q?=20fzf=20+=20wl-copy=20vault=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bwp: select entry → copy password to clipboard bwc: select entry → copy TOTP/2FA code to clipboard bwu: select entry → copy username/email to clipboard Single writeShellApplication dispatched by $0, three symlinks (bwp/bwc/bwu) installed via home.packages. --- .../home-manager/bitwarden-cli/default.nix | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/home-manager/bitwarden-cli/default.nix b/modules/home-manager/bitwarden-cli/default.nix index 4b3706d..1673b11 100644 --- a/modules/home-manager/bitwarden-cli/default.nix +++ b/modules/home-manager/bitwarden-cli/default.nix @@ -3,9 +3,32 @@ config, pkgs, ... -}: -{ +}: let + bw = pkgs.writeShellApplication { + name = "bw"; + runtimeInputs = with pkgs; [ rbw fzf wl-clipboard libnotify ]; + text = '' + set -euo pipefail + cmd="$(basename "$0")" + entry="$(rbw list --fields=id,name,user --format=tsv \ + | fzf --with-nth=2.. --delimiter=$'\t')" + [ -z "$entry" ] && exit 0 + + id="$(printf '%s' "$entry" | cut -f1)" + + case "$cmd" in + bwc) val="$(rbw code "$id")" ;; + bwu) val="$(rbw get --field username "$id")" ;; + bwp) val="$(rbw get "$id")" ;; + *) exit 1 ;; + esac + + printf '%s' "$val" | wl-copy + notify-send -t 1200 "bw: copied $cmd" + ''; + }; +in { options.custom = { bitwarden.enable = lib.mkEnableOption "enable bitwarden - CLI password manager"; }; @@ -20,5 +43,16 @@ base_url = "https://pass.joaoporta.com"; }; }; + + home.packages = + let mkBin = name: + pkgs.symlinkJoin { + inherit name; + paths = [ bw ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = "ln -sf ${bw}/bin/bw $out/bin/${name}"; + }; + in + builtins.map mkBin [ "bwp" "bwc" "bwu" ]; }; }