#!/bin/sh
#
# prompt for a password via fuzzel
# generate new password if it doesn't exist
# then type the selected password via wtype

name=$(pass ls | fuzzel --dmenu "$@") || exit
{
  pass show "${name}" \
    || { printf y | pass add "${name}" >/dev/null && pass show "${name}"; }
} \
  | head -n 1 | tr -d '\n' | wtype -
