1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/bin/sh usage () { cat >&2 <<-EOF usage: ${0} password_regexp EOF } log () { echo ["${0}"] $@ >&2 } main() { # verify arguments [ "${#}" -ne 1 ] && usage && exit 1 # retrieve password log "retrieving password for : ${1}" gopass show --password $(gopass ls --flat | grep "${1}" | head -n 1) } main $@