From ea4e649b88bfe7872e80dce9c6da2e6a893bc3e7 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 29 Nov 2019 09:35:15 +1300 Subject: [PATCH] wrap editor in script --- .bin/genpw-editor | 15 +++++++++++++++ .gitignore.d/pass | 1 + .zsh/aliases/genpw | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 .bin/genpw-editor 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"; } -- 2.39.2