Skip to content

Instantly share code, notes, and snippets.

@notdodo
Created February 23, 2020 21:55
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 notdodo/5593bcc324251316e055df01ded11c2f to your computer and use it in GitHub Desktop.
Save notdodo/5593bcc324251316e055df01ded11c2f to your computer and use it in GitHub Desktop.
rofi menu to help read Lastpass passwords.
#!/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