Skip to content

Instantly share code, notes, and snippets.

@agarzola
Last active March 5, 2017 13:03
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 agarzola/46f45116eb1ff5049edf25ba41c10c9b to your computer and use it in GitHub Desktop.
Save agarzola/46f45116eb1ff5049edf25ba41c10c9b to your computer and use it in GitHub Desktop.
Shortcuts to my most used lpass commands
function lastpass () {
if [ "$1" ]; then
if [ "$2" ]; then
if [ "$1" = "all" ] || [ "$1" = "password" ] || [ "$1" = "username" ] || [ "$1" = "url" ] || [ "$1" = "notes" ]; then
requested_part="$1"
else
requested_part="field=$1"
fi
requested_account="$2"
else
requested_part=password
requested_account="$1"
fi
lpass show --clip --$requested_part $requested_account && printf "${requested_part//field=/} copied to clipboard\n";
else
printf "Copy lastpass fields to your clipboard.\nUsage: takes one or two arguments —\n 1. an optional field name (defaults to password)\n 2. an account name\n\n e.g. lastpass username github\n ⮑ github username is copied to your clipboard\n\n lastpass github\n ⮑ github password is copied to your clipboard\n";
fi
}
function findpass () {
if [ "$1" ]; then
lpass ls | grep $1
else
printf "List lastpass accounts matching your query.\nUsage: one argument — a query\n\n e.g. findpass git\n ⮑ list of accounts stored in lastpass that match \`git\`\n";
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment