Created
February 23, 2020 21:55
-
-
Save notdodo/5593bcc324251316e055df01ded11c2f to your computer and use it in GitHub Desktop.
rofi menu to help read Lastpass passwords.
This file contains 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 zsh | |
if ! hash lpass 2>/dev/null; then | |
echo "Lastpass not installed" | |
exit -1 | |
fi | |
if ! hash xsel 2>/dev/null; then | |
echo "xsel not installed" | |
exit -1 | |
fi | |
function usage() { | |
echo "USAGE: " | |
echo "" | |
echo "$0 EMAILADDRESS" | |
} | |
while [ "$1" != "" ]; do | |
case $1 in | |
-h | --help) | |
shift | |
usage | |
exit 0 | |
;; | |
*) | |
EMAIL=$1 | |
;; | |
esac | |
shift | |
done | |
if [ -z "$EMAIL" ]; then | |
echo "Mandatory argument missing" | |
echo "" | |
usage | |
exit 1 | |
fi | |
status="$(lpass status)" | |
if [ "$status" = "Not logged in." ]; then | |
lpass login "$EMAIL" | |
fi | |
line=$(lpass ls | rofi -i -p "Select the entry to copy" "$@" -dmenu) | |
if [ -n "$line" ]; then | |
pass_id=$(rg -o 'id: (\d+)' -r '$1' <<<${line}) | |
echo -n "$(lpass show "$pass_id" -p)" | xsel --clipboard | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment