Advertisement
Guest User

Untitled

a guest
May 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. src/password-store.sh | 19 +++++++++++++------
  2. 1 file changed, 13 insertions(+), 6 deletions(-)
  3.  
  4. diff --git a/src/password-store.sh b/src/password-store.sh
  5. index d535a74..f4e1cfe 100755
  6. --- a/src/password-store.sh
  7. +++ b/src/password-store.sh
  8. @@ -223,8 +223,8 @@ cmd_usage() {
  9. List passwords.
  10. $PROGRAM find pass-names...
  11. List passwords that match pass-names.
  12. - $PROGRAM [show] [--clip,-c] pass-name
  13. - Show existing password and optionally put it on the clipboard.
  14. + $PROGRAM [show] [--clip,-c] [--hidden,-h] pass-name
  15. + Show existing password and optionally put it on the clipboard or hide it.
  16. If put on the clipboard, it will be cleared in $CLIP_TIME seconds.
  17. $PROGRAM grep search-string
  18. Search for password files containing search-string when decrypted.
  19. @@ -294,23 +294,30 @@ cmd_init() {
  20. }
  21.  
  22. cmd_show() {
  23. - local opts clip=0
  24. - opts="$($GETOPT -o c -l clip -n "$PROGRAM" -- "$@")"
  25. + local opts clip=0 hidden=0
  26. + opts="$($GETOPT -o ch -l clip,hidden -n "$PROGRAM" -- "$@")"
  27. local err=$?
  28. eval set -- "$opts"
  29. while true; do case $1 in
  30. -c|--clip) clip=1; shift ;;
  31. + -h|--hidden) hidden=1; shift ;;
  32. --) shift; break ;;
  33. esac done
  34.  
  35. - [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip,-c] [pass-name]"
  36. + [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip,-c] [--hidden,-h] [pass-name]"
  37.  
  38. local path="$1"
  39. local passfile="$PREFIX/$path.gpg"
  40. check_sneaky_paths "$path"
  41. if [[ -f $passfile ]]; then
  42. if [[ $clip -eq 0 ]]; then
  43. - $GPG -d "${GPG_OPTS[@]}" "$passfile" || exit $?
  44. + if [[ $hidden -eq 0 ]]; then
  45. + $GPG -d "${GPG_OPTS[@]}" "$passfile" || exit $?
  46. + else
  47. + local pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | head -n 1)"
  48. + [[ -n $pass ]] || exit 1
  49. + echo -e "\e[0;31;41m$pass\e[0m"
  50. + fi
  51. else
  52. local pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | head -n 1)"
  53. [[ -n $pass ]] || exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement