#!/usr/bin/env bash ## Generate a password using the password manager `pass` and then open the ## password's file in the default text editor. ## ## Usage: pass-generate [...] [] ## ## Dependencies: GNU coreutils, GNU findutils, GNU sed, pass set -euo pipefail shopt -s inherit_errexit die() { echo -e "$(basename "$0"): $1" >&2; exit 1; } [[ " $* " =~ ' --help ' ]] && sed -n 's/^## *//p' "$0" && exit (( $# >= 1 )) || die 'missing argument' pass generate -c "$@" find "${PASSWORD_STORE_DIR-~/.password-store}"/* -mmin -0.05 | xargs basename -s .gpg | xargs -o pass edit