Last active
December 20, 2015 08:18
-
-
Save BlinkyStitt/6099189 to your computer and use it in GitHub Desktop.
Take a domain and search in a subdirectory of pass for matching username and passwords to put into the clipboard. Also displays metadata that one day maybe a password manager could use for autofill. Uses pbcopy, so only works with OSX. Would be nice to make this work on linux, too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Take a domain and search in a subdirectory of pass for matching username and | |
# password to put into the clipboard. | |
if [[ $# -lt 1 ]]; then | |
echo "Usage: $0 domain" | |
exit 1 | |
fi | |
BASE_PATH="autofill" | |
DOMAIN=$1 | |
META_SUFFIX="__metadata" | |
PASS_PATH="${BASE_PATH}/${DOMAIN}" | |
USERNAMES=( $(pass ls $PASS_PATH | sed 1d | grep -v $META_SUFFIX | cut -d' ' -f2) ) | |
if [[ $? -ne 0 ]]; then | |
exit $? | |
fi | |
if [[ -z $USERNAMES ]]; then | |
echo "No usernames found for ${DOMAIN}." | |
exit 1 | |
fi | |
j=0 | |
for i in "${USERNAMES[@]}" | |
do | |
echo "$j: $i" | |
let j=$j+1 | |
done | |
echo -n "Select a username: [0] " | |
read USER_ID | |
USER=${USERNAMES[${USER_ID}]} | |
if [[ -z $USER ]]; then | |
echo "No username found with that id." | |
exit 1 | |
fi | |
USER_PATH="${PASS_PATH}/${USER}" | |
META_PATH="${USER_PATH}${META_SUFFIX}" | |
# show metadata | |
pass show $META_PATH | |
# put username into the clipboard | |
echo -n $USER | pbcopy | |
read -p "'${USER}' is now in the clipboard. Press [Enter] key to continue..." | |
# put the password into the clipboard | |
pass show --clip $USER_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One problem might be that you will have to decrypt twice since the metadata is in a separate encrypted file.