<html><head></head><body>Here's a script I use all the time.<br>
<br>
It generates a<br>
password, and opens an editor for you. The password will be in the<br>
clipboard (middle-mouse button for me) so you can paste into the site<br>
and actually register successfully before saving and committing.<br>
<br>
Call it with:<br>
<br>
password_<a href="http://edit.sh">edit.sh</a> <filename><br>
<br>
Script follows:<br>
---<br>
#!/usr/bin/env bash<br>
<br>
# A simple wrapper for pass edit. Takes one argument, and that is the<br>
# password file to open (which can be new). As a convenience, a new<br>
# password is generated and placed in the clipboard so you can paste<br>
# it with Mouse3.<br>
<br>
if [ $# -eq 0 ]; then<br>
echo "No arguments provided"<br>
exit 1<br>
fi<br>
<br>
CLIP_TIME=45<br>
<br>
# Borrowing from pass<br>
clip() {<br>
# This base64 business is because bash cannot store binary data in a<br>
# shell variable. Specifically, it cannot store nulls nor<br>
# (non-trivally) store trailing new lines.<br>
local sleep_argv0="password store sleep on display $DISPLAY"<br>
local before<br>
local now<br>
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5<br>
before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | base64)"<br>
echo -n "$1" | xclip -selection "$X_SELECTION" || \<br>
die "Error: Could not copy data to the clipboard"<br>
(<br>
( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )<br>
now="$(xclip -o -selection "$X_SELECTION" | base64)"<br>
[[ $now != $(echo -n "$1" | base64) ]] && before="$now"<br>
<br>
# It might be nice to programmatically check to see if klipper<br>
# exists, as well as checking for other common clipboard<br>
# managers. But for now, this works fine -- if qdbus isn't there<br>
# or if klipper isn't running, this essentially becomes a no-op.<br>
#<br>
# Clipboard managers frequently write their history out in<br>
# plaintext, so we axe it here:<br>
qdbus org.kde.klipper \<br>
/klipper org.kde.klipper.klipper.clearClipboardHistory \<br>
&>/dev/null<br>
<br>
echo "$before" | base64 -d | xclip -selection "$X_SELECTION"<br>
) 2>/dev/null & disown<br>
#echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."<br>
}<br>
<br>
# -B - don't use ambiguious characters<br>
# -s - added randomness<br>
# 20 chars long<br>
# 1 output only<br>
pw=$(pwgen -B -s 20 1)<br>
<br>
# Copy password to clipboard<br>
clip "$pw"<br>
<br>
# Open editor, paste password with Mouse3<br>
pass edit "$1"<br>
<br><br><div class="gmail_quote">Kenny Evitt <kenny.evitt@gmail.com> skrev: (15 juli 2016 21:49:26 CEST)<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">I often want to add an entry but also generate a new random password and add additional info ('edit') and, given that I'm tracking the history of my entries with Git, it'd be nice (or nicest) to do all of that as a single commit. Besides the Git history, it'd also be nice to do all of that as a single `pass ...` command too.<div><br /></div><div>The closest I can come to this is to run `pass edit ...`. In my editor (Vim) I can insert the output of running `pwgen` easily enough (by running the Vim command `:r !pwgen -s -y 32` or similar), but it'd be nice for `pass edit ...` to insert a password for me (if no existing entry matches the path I provide) or for another command to do so instead of `edit`.</div></div>
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />Password-Store mailing list<br />Password-Store@lists.zx2c4.com<br /><a href="http://lists.zx2c4.com/mailman/listinfo/password-store">http://lists.zx2c4.com/mailman/listinfo/password-store</a><br /></pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>