Skip to content

Instantly share code, notes, and snippets.

@lbonn
Created March 13, 2017 12:34
Show Gist options
  • Save lbonn/6167b008b9295d811b6d940c08359e3b to your computer and use it in GitHub Desktop.
Save lbonn/6167b008b9295d811b6d940c08359e3b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# custom version: can match user
shopt -s nullglob globstar
if [[ $1 == "--user" ]]; then
grepstr='(?<=user: ).*$'
shift
fi
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[@]}" | rofi -p 'pass ' -dmenu "$@")
[[ -n "$password" ]] || exit
pass show "$password" |
(([ -z "$grepstr" ] && cat) || grep -oP "$grepstr" ) | # lol
awk 'BEGIN{ORS=""} {print; exit}' |
xdotool type --clearmodifiers --file -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment