From: martin f. krafft Date: Thu, 28 Nov 2019 20:35:15 +0000 (+1300) Subject: wrap editor in script X-Git-Url: https://git.madduck.net/etc/pass.git/commitdiff_plain/ea4e649b88bfe7872e80dce9c6da2e6a893bc3e7?ds=inline wrap editor in script --- diff --git a/.bin/genpw-editor b/.bin/genpw-editor new file mode 100755 index 0000000..108f1b6 --- /dev/null +++ b/.bin/genpw-editor @@ -0,0 +1,15 @@ +#!/bin/sh +set -eu + +if command -v diceware >/dev/null; then + PW_GENERATOR='diceware -s2' + +elif command -v pwgen >/dev/null; then + PW_GENERATOR='pwgen -y 20 1' + +else + PW_GENERATOR='dd if=/dev/random bs=256 count=1 | base64' + +fi + +exec vim -c 'set noshelltemp' -c "0read! $PW_GENERATOR" -c 2d -n diff --git a/.gitignore.d/pass b/.gitignore.d/pass index 8b3844c..61a21a1 100644 --- a/.gitignore.d/pass +++ b/.gitignore.d/pass @@ -1,4 +1,5 @@ * +!/.bin/genpw-editor !/.gitignore.d/pass !/.zsh/aliases/genpw !/.zsh/aliases/getpw diff --git a/.zsh/aliases/genpw b/.zsh/aliases/genpw index 7b9f997..c497602 100644 --- a/.zsh/aliases/genpw +++ b/.zsh/aliases/genpw @@ -1 +1 @@ -() { EDITOR="vim -c 'set noshelltemp' -c '0read! diceware -s ${2:-1}' -c 2d -n" pass edit "$1"; } +() { EDITOR="genpw-editor $2" pass edit "$1"; }