Last active
May 6, 2022 21:02
-
-
Save benders/a76cb24244746036088e2d4e2a31ba75 to your computer and use it in GitHub Desktop.
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
# Add to .profile / .zprofile | |
# Requires 1Password CLI v2 https://app-updates.agilebits.com/product_history/CLI2 | |
# To setup: op account add | |
# | |
# Change ITEM to choose where 1Password looks | |
# | |
op-clip-okta() { | |
ITEM="Okta" | |
echo "Fetching ${ITEM} OTP from 1Password" | |
OP_ACCOUNT=$(op account list --format=json | jq -r '.[0].user_uuid') | |
eval $(op signin --session=$(eval echo \$OP_SESSION_${OP_ACCOUNT})) | |
item_password=$(op item get ${ITEM} --fields='password' --format=json | jq -r '.value') | |
item_totp=$(op item get ${ITEM} --otp) | |
echo -n $(echo "${item_password},${item_totp}") | pbcopy | |
echo "Password and OTP code copied to clipboard" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment