nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

passmenu (615B)


      1 #!/bin/bash
      2 set -euo pipefail
      3 
      4 export PASSWORD_STORE_CLIP_TIME=60
      5 shopt -s nullglob globstar
      6 
      7 prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
      8 prefix="${prefix%/}/"
      9 
     10 if [ ! -d "$prefix" ]; then
     11 	echo "Error: Password store '$prefix' not found" >&2
     12 	exit 1
     13 fi
     14 
     15 password_files=("$prefix"**/*.gpg)
     16 password_files=("${password_files[@]#"$prefix"}")
     17 password_files=("${password_files[@]%.gpg}")
     18 
     19 password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
     20 [ -z "$password" ] && exit 0
     21 
     22 if [[ "$password" == *otp* ]]; then
     23 	pass otp -c "$password" >/dev/null 2>&1
     24 else
     25 	pass show -c "$password" >/dev/null 2>&1
     26 fi