Gopass: Always copy passwords to clipboard

Created on 19 Mar 2020  路  8Comments  路  Source: gopasspw/gopass

Summary

It would be great if I could configure gopass to always copy passwords to the clipboard, without using -c. I almost never need to actually see a password and would prefer to simply use -f in those cases.

Wouldn't it make sense to always copy the password if the option autoclip is set to true?

In my opinion this would also be a much cleaner behaviour of autoclip than the current behaviour:
According to the docs autoclip only applies to generate, not to show (but see #1191). But since #685 it also applies to show under some circumstances (namely if safecontent is set to true and the password does not have safe content).

Steps To Reproduce

Set autoclip to true
Run gopass some/password
The password will be printed.

Expected behavior

The password should be copied instead.

Environment

  • OS: Arch Linux
  • gopass Version: gopass 1.8.6 (2020-02-29 13:42:01) go1.14 linux amd64
  • Installation method: Arch Linux Repos
ux

All 8 comments

I have autoclip turned on but often use show without -c to actually show the whole entry. But I agree, the setting(s) could be a bit disentangled and enhanced. Any suggestions how to structure functionality and config here?

Maybe one could add another option alwaysclip. Then the user could choose between

  • default behaviour: never copy to clipboard unless using '-c'
  • alwaysclip: always copy to clipboard unless using '-f'
  • autoclip: current mixture of both.
    (I would prefer to change the behaviour of the existing autoclip option, but I guess backwards compatibility forbids this.)

"copy to clipboard" refers to the whole password if safecontent is false, or only the first line if safecontent is true.

We have way to many configuration options already. I definitely don't want to increase that number.

Changing autoclip to also cover show and other subcommands sounds good to me.

What about using autoclip to always suppress printing passwords and copying to the clipboard instead.

So far this would apply to show and generate, in the future possible to other operations, too.

I'd default to having autoclip false. Personally I don't like programs messing around with my clipboard and prefer to print it to the screen. Since my credentials are almost always autogenerated, long, cryptic and unique to a service I don't mind passers by so much.

Sounds good to me. Apart from the default, that's the initial suggestion from @MartinAltmayer but that can be configured to match personal preferences.

Thanks for implementing a fix!

Here are some behaviours that look incorrect to me (unless otherwise specified I assume autoclip and safecontent to be false):

  • gopass show -c temp/test will not copy the secret to clipboard (see #1317).
  • gopass show -c --alsoclip temp/test will copy all lines of the secret, contradicting the description of alsoclip in gopass help show.
  • With autoclip set to true, gopass show temp/test will copy the first line and display nothing. I could not find a way to view/copy the other lines (with --force, it will copy and display the first line).

To reduce the number of different cases, I believe it would be simpler to have "autoclip" be equivalent to --clip, similar to this line:

ctx = WithClip(ctx, c.Bool("clip") || c.Bool("alsoclip") || ctxutil.IsAutoClip(ctx))

Let me know if I can help in fixing this!

Thanks for implementing this! I think I tried all combinations of autoclip, safecontent, -c, -C, -f and couldn't find any issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gnosthi picture gnosthi  路  5Comments

jungle-boogie picture jungle-boogie  路  7Comments

nostdm picture nostdm  路  5Comments

FlorinAndrei picture FlorinAndrei  路  7Comments

sevenmaxis picture sevenmaxis  路  4Comments