getlogin() { local pw uid parse_pass_output() { local key rest pw while read key rest; do if [ -z "$pw" ]; then pw="$key" echo "pw=$pw" continue fi if [ -z "$uid" ] && [ -n "$rest" ]; then case "${key%:}" in login|user|username|id|userid) echo uid="$rest"; break;; esac fi done } eval $(pass "$1" | parse_pass_output) [ -n "$uid" ] || uid="${1##*/}" xclip_() { # -quiet is not: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103990 xclip -rmlastnl -loops 1 -selection clipboard -quiet 2>/dev/null } echo >&2 "Go paste the UID: $uid" echo "$uid" | xclip_ echo >&2 "Now go paste the password" echo "$pw" | xclip_ } compdef getlogin=pass # vim:ft=zsh