X-Git-Url: https://git.madduck.net/etc/pass.git/blobdiff_plain/32c81d22359414b4168d2ea74186143b28d31387..ae0422c6f35b35e2b85cffc4aaa857c25b860192:/.zsh/zshrc/parts.d/50-pass diff --git a/.zsh/zshrc/parts.d/50-pass b/.zsh/zshrc/parts.d/50-pass new file mode 100644 index 0000000..da55c20 --- /dev/null +++ b/.zsh/zshrc/parts.d/50-pass @@ -0,0 +1,36 @@ +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