]> git.madduck.net Git - etc/pass.git/blob - .zsh/zshrc/parts.d/50-pass

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

add getlogin function
[etc/pass.git] / .zsh / zshrc / parts.d / 50-pass
1 getlogin() { 
2   local pw uid
3   parse_pass_output() {
4     local key rest pw
5     while read key rest; do
6       if [ -z "$pw" ]; then
7         pw="$key"
8         echo "pw=$pw"
9         continue
10       fi
11
12       if [ -z "$uid" ] && [ -n "$rest" ]; then
13         case "${key%:}" in
14           login|user|username|id|userid) echo uid="$rest"; break;;
15         esac
16       fi
17     done
18   }
19
20   eval $(pass "$1" | parse_pass_output)
21
22   [ -n "$uid" ] || uid="${1##*/}"
23
24   xclip_() {
25     # -quiet is not: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103990
26     xclip -rmlastnl -loops 1 -selection clipboard -quiet 2>/dev/null
27   }
28
29   echo >&2 "Go paste the UID: $uid"
30   echo "$uid" | xclip_
31   echo >&2 "Now go paste the password"
32   echo "$pw" | xclip_
33 }
34 compdef getlogin=pass
35
36 # vim:ft=zsh