passmenu 589 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. shopt -s nullglob globstar
  3. typeit=0
  4. if [[ $1 == "--type" ]]; then
  5. typeit=1
  6. shift
  7. fi
  8. prefix=${PASSWORD_STORE_DIR-~/.password-store}
  9. password_files=( "$prefix"/**/*.gpg )
  10. password_files=( "${password_files[@]#"$prefix"/}" )
  11. password_files=( "${password_files[@]%.gpg}" )
  12. password=$(printf '%s\n' "${password_files[@]}" | dmenu.sh -p 'password:' -l 20 "$@")
  13. [[ -n $password ]] || exit
  14. if [[ $typeit -eq 0 ]]; then
  15. pass "$password" | xsel -ip -t 10000
  16. else
  17. pass "$password" | { IFS= read -r pass; printf %s "$pass"; } |
  18. xdotool type --clearmodifiers --file -
  19. fi