Skip to content

Instantly share code, notes, and snippets.

@sigio
Created July 30, 2015 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sigio/93d7e22b67521867dcc0 to your computer and use it in GitHub Desktop.
Save sigio/93d7e22b67521867dcc0 to your computer and use it in GitHub Desktop.
Passmenu / dmenu interface for pass(1)
#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
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[@]}" | dmenu "$@")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
xdotool - <<<"type --clearmodifiers -- $(pass show "$password" | head -n 1)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment