Guest User

Untitled

a guest
Nov 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. shopt -s nullglob globstar
  4.  
  5. typeit=0
  6. if [[ $1 == "--type" ]]; then
  7. typeit=1
  8. shift
  9. fi
  10.  
  11. prefix=${PASSWORD_STORE_DIR-~/.password-store}
  12. password_files=( "$prefix"/**/*.gpg )
  13. password_files=( "${password_files[@]#"$prefix"/}" )
  14. password_files=( "${password_files[@]%.gpg}" )
  15.  
  16. password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
  17.  
  18. [[ -n $password ]] || exit
  19.  
  20. if [[ $typeit -eq 0 ]]; then
  21. if [[ "$password" == otp/* ]]; then
  22. pass otp -c "$password" 2>/dev/null
  23. else
  24. pass show -c "$password" 2>/dev/null
  25. fi
  26. else
  27. result=""
  28. if [[ "$password" == otp/* ]]; then
  29. result=$(pass otp "$password")
  30. else
  31. result=$(pass show "$password")
  32. fi
  33. echo "$result" | { read -r pass; printf %s "$pass"; } |
  34. xdotool type --clearmodifiers --file -
  35. fi
Add Comment
Please, Sign In to add comment