commit - ee89c9f13862af202295b29031eb7cb52a102e88
commit + c992a1e9b1b3f12475053356a5e9e2f0381211f3
blob - eb099a81d3d91d86457e11ad8d302f809ac5f4f7
blob + 3f3457fa3dc0ba04d7c75cc02170f341bbacd996
--- plass
+++ plass
my $gpg = $ENV{'PLASS_GPG'} // 'gpg';
my @gpg_flags = qw(--quiet --compress-algo=none --no-encrypt-to --use-agent);
-my $default_chars = $ENV{'PLASS_CHARS'} // '!-~';
-my $default_length = $ENV{'PLASS_LENGTH'};
-if (!defined($default_length) || $default_length <= 0) {
- $default_length = 32;
-}
-
my %subcmd = (
cat => [\&cmd_cat, "entries..."],
find => [\&cmd_find, "[pattern]"],
- gen => [\&cmd_gen, "[-nq] [-c chars] [-l length] entry"],
mv => [\&cmd_mv, "from to"],
rm => [\&cmd_rm, "entries..."],
tee => [\&cmd_tee, "[-q] entry"],
return $f;
}
-# tr -cd -- $chars < /dev/urandom | dd bs=$len count=1 status=none
-sub gen {
- my ($chars, $length) = @_;
- my $pass = "";
-
- open(my $fh, '<:raw', '/dev/urandom')
- or die "can't open /dev/urandom: $!";
- my $l = $length;
- while ($l >= 0) {
- read($fh, my $t, $length * 4)
- or die "failed to read /dev/urandom: $!";
- $t =~ s/[^$chars]//g;
- $l -= length($t);
- $pass .= $t;
- }
- close($fh);
-
- return substr($pass, 0, $length);
-}
-
sub mkdirs {
my $dir = shift;
my $parent = dirname $dir;
map { say $_ } passfind(shift @ARGV);
}
-sub cmd_gen {
- my $chars = $default_chars;
- my $length = $default_length;
- my $nop;
- my $q;
-
- GetOptions(
- 'c=s' => sub { $chars = $_[1] },
- 'h|?' => \&usage,
- 'l=i' => sub { $length = $_[1] },
- 'n' => \$nop,
- 'q' => \$q,
- ) or usage;
-
- my $pass = gen($chars, $length) . "\n";
- if ($nop) {
- say $pass;
- return;
- }
-
- usage if @ARGV != 1;
-
- my $name = shift @ARGV;
- my $file = name2file $name;
- my $renamed = -f $file;
-
- writepass($file, $pass);
- got_add $file;
- got_ci($renamed ? "update $name" : "+$name");
- say $pass unless $q;
-}
-
# TODO: handle moving directories?
sub cmd_mv {
GetOptions('h|?' => \&usage) or usage;
blob - a03ee671274d85976574254d923ccb99acb465b6
blob + 7d082e280d93dd2cc7c3288bcada4baa9b8a8e87
--- plass.1
+++ plass.1
.Xr got 1
repository with a worktree checked out at
.Pa ~/.password-store
-.Pq or Ev PLASS_STORE .
The only restriction is that a special file called
.Pa .gpg-id
containing the GPG recipient must exist in the root of the directory tree
.It Cm find Op Ar pattern
Print the entries of the store one per line, optionally filtered by
.Ar pattern .
-.It Cm gen Oo Fl nq Oc Oo Fl c Ar chars Oc Oo Fl l Ar length Oc Ar entry
-Generate and persist a password for the given
-.Ar entry
-in the store.
-.Fl c
-can be used to control the characters allowed in the password
-(by default
-.Dq !-~
-i.e. all the printable ASCII characters)
-and
-.Fl l
-the length
-.Pq 32 by default .
-Unless the
-.Fl q
-flag is provided, print the generated password.
-If the
-.Fl n
-flag is given the password won't be persisted and the
-.Ar entry
-argument is optional.
.It Cm mv Ar from Ar to
Rename a password entry, doesn't work with directories.
.Ar from
.El
.Sh ENVIRONMENT
.Bl -tag -width Ds
-.It Ev PLASS_CHARS
-default range of characters to use to generate passwords.
.It Ev PLASS_GOT
Path to the
.Xr got 1
Path to the
.Xr gpg 1
executable.
-.It Ev PLASS_LENGTH
-Default length for the generated passwords.
.It Ev PLASS_STORE
-Path to the password store directory tree.
+Alternative path to the password store directory tree.
.El
.Sh FILES
.Bl -tag -width Ds
and check out it again using
.Xr got 1 .
.Pp
-To generate a temporary random password use
+Generate a random password and save it to the clipboard:
.Bd -literal -offset indent
-$ plass gen -n
+$ pwg | plass tee entry/name | xsel -b
.Ed
.Pp
Display the entries matching
.Sh SEE ALSO
.Xr got 1 ,
.Xr gpg 1 ,
-.Xr pass 1
+.Xr pass 1 ,
+.Xr pwg 1
.Sh HISTORY
.Nm
was heavily influenced by