Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

  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. entry=$(printf '%s\n' "${password_files[@]}" | sort | dmenu -l 7 -p "Pass" -i "$@")
  13. [[ -n $entry ]] || exit
  14. action=$(echo -e "Username\nPassword\nTOTP" | dmenu -p "Entry" -i )
  15. case "$action" in
  16. Username)
  17. username=$(echo "$entry" | rev | cut -d"/" -f 1 | rev)
  18. echo "$username" | xclip -selection clipboard
  19. notify-send -a " Password Manager" "Username copied to clipboard";;
  20. Password)
  21. if [[ $typeit -eq 0 ]]; then
  22. pass show -c "$entry" 2>/dev/null
  23. else
  24. pass show "$entry" | { IFS= read -r pass; printf %s "$pass"; } |
  25. xdotool type --clearmodifiers --file -
  26. fi
  27. notify-send -a " Password Manager" "Password copied to clipboard";;
  28. TOTP)
  29. if [[ $typeit -eq 0 ]]; then
  30. pass otp -c "$entry" 2>/dev/null
  31. else
  32. pass otp "$entry" | { IFS= read -r pass; printf %s "$pass"; } |
  33. xdotool type --clearmodifiers --file -
  34. fi
  35. notify-send -a " Password Manager" "TOTP copied to clipboard";;
  36. esac