Created
November 7, 2020 15:16
-
-
Save mattcanty/b5cda46f10539a73ffd7bc574b0b2f3a to your computer and use it in GitHub Desktop.
1Password CLI Shell Functions
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
otp() { | |
ITEM_NAME=$1 | |
TOTP=$(op get totp $ITEM_NAME --vault Personal 2>&1) | |
if [[ $TOTP == *"You are not currently signed in"* ]]; then | |
eval $(op signin my.1password.com) | |
totp $ITEM_NAME | |
return | |
fi | |
echo $TOTP | xclip -sel clip | |
echo "TOTP copied to the clipboard ($TOTP)" | |
} |
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
pass() { | |
ITEM_NAME=$1 | |
ITEM=$(op get item $ITEM_NAME --vault Personal 2>&1) | |
if [[ $ITEM == *"You are not currently signed in"* ]]; then | |
eval $(op signin my.1password.com) | |
pass $ITEM_NAME | |
return | |
fi | |
PASSWORD=$(echo $ITEM | jq -r '.details.fields[] | select(.name == "password") | .value') | |
echo $PASSWORD | xclip -sel clip | |
echo "Password copied to the clipboard" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment