Skip to content

Instantly share code, notes, and snippets.

@DepthDeluxe
Last active November 11, 2019 22:06
Show Gist options
  • Save DepthDeluxe/15aecc68ecb42e028c96bf30cfa949e7 to your computer and use it in GitHub Desktop.
Save DepthDeluxe/15aecc68ecb42e028c96bf30cfa949e7 to your computer and use it in GitHub Desktop.
Combines the power of lastpass cli and fzf to offer an interactive fuzzy finding password experience on the command line. Lists all lastpass passwords and pipes into FZF to search by name. Once selected, the script copies desired password to the system clipboard.
#!/bin/bash
lpass_data=$(lpass ls)
if [[ "$lpass_data" == "" ]]; then
echo 'Error: You are likely not logged into lastpass, attempting to login'
exit 1
fi
chosen_element=$(echo "$lpass_data" | fzf)
if [[ "$!" -eq 0 ]]; then
chosen_element_id=$(echo "$chosen_element" | egrep -o 'id: [0-9]+' | awk '{ print $2; }')
echo "Chose id: $chosen_element_id"
lpass show --password --clip "$chosen_element_id"
else
echo 'Cancelled operation...'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment