nix-config/macos/choose-pass.nix

19 lines
497 B
Nix
Raw Permalink Normal View History

2022-01-18 09:32:55 +01:00
{ config, pkgs, ... }:
pkgs.writeScriptBin "choose-pass" ''
#!${pkgs.dash}/bin/dash
prefix=''${PASSWORD_STORE_DIR-"''${HOME}/.password-store"}
sel=$(
${pkgs.findutils}/bin/find "$prefix" -name '*.gpg' | \
${pkgs.gnused}/bin/sed -E "s|^''${prefix}/?||" | \
${pkgs.gnused}/bin/sed 's/.gpg$//' | \
/usr/local/bin/choose -f Inter -s 20 -c fbf1c7 -b 458588
)
[ -n "$sel" ] || exit
${pkgs.pass}/bin/pass show "$sel" | tr -d "\n" | /usr/bin/pbcopy
''