Skip to content

Instantly share code, notes, and snippets.

@cfillion
Created January 8, 2017 11:53
Show Gist options
  • Save cfillion/babce888699659c2a572c2c4d5eaf467 to your computer and use it in GitHub Desktop.
Save cfillion/babce888699659c2a572c2c4d5eaf467 to your computer and use it in GitHub Desktop.
Port of passmenu for macOS using cfillion/cpmenu and cliclick
#!/usr/bin/env bash
# Forked from https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu
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[@]}" | cpmenu "$@")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
pass show "$password" | { read -r pass; printf t:%s "$pass"; } | cliclick -f -
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment