rbw: rbw-fzf

This commit is contained in:
Zynh Ludwig 2024-08-24 15:13:20 -07:00
parent e0a6ce3b64
commit b6fca59334

View file

@ -3,6 +3,24 @@
let let
cfg = config.snowhawk.rbw; cfg = config.snowhawk.rbw;
rbw-fzf = pkgs.writeShellApplication {
name = "rbw-fzf";
runtimeInputs = with pkgs; [ rbw fzf perl findutils coreutils jq ];
text = /*bash*/ ''
rbw ls --fields name,user |
sort -bi |
perl -ple 's/^([^\t]*)\t([^\t]*)$/$1 ($2)/gm' |
fzf --tmux --no-sort --with-shell='bash -c' \
--preview="echo {} | perl -plE 's/^(.*) \((.*)?\)$/\"\$1\" \"\$2\"/' |
xargs rbw get --full --raw | \
jq --color-output 'if .data.password != \"\" then setpath([\"data\", \"password\"]; \"************\") else . end | del(.history) | del(.id) | walk(if type == \"object\" then map_values(. // empty) else . end)'" \
--preview-label="Vault Item" --preview-window=wrap |
perl -plE 's/^(.*) \((.*)?\)$/"$1" "$2"/' |
xargs -r rbw get |
wl-copy
'';
};
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf mkEnableOption;
in in
{ {
@ -13,9 +31,12 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.rbw.enable = true; programs.rbw.enable = true;
home.packages = with pkgs; [ home.packages =
with pkgs; [
rbw rbw
pinentry-tty pinentry-tty
rbw-fzf
]; ];
}; };
} }