#!/usr/bin/env bash shopt -s nullglob globstar typeit=0 user= both=0 while [[ $# -gt 0 ]]; do case $1 in "--type") typeit=1; shift;; "--user") user=-u; shift;; "--both") both=1; shift;; *) break;; esac done prefix=${PASSWORD_STORE_DIR-~/.password-store} password_files=( "$prefix"/**/*.gpg ) password_files=( "${password_files[@]#"$prefix"/}" ) password_files=( "${password_files[@]%.gpg}" ) password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@") [[ -n $password ]] || exit xdo() { local user=$1 pass show $user "$password" | { IFS= read -r pass; printf %s "$pass"; } | xdotool type --clearmodifiers --file - } if [[ $typeit -eq 0 ]]; then pass show $user -c "$password" 2>/dev/null elif [[ $both -eq 0 ]]; then xdo $user else xdo -u xdotool key Tab xdo fi