Skip to content

Instantly share code, notes, and snippets.

@benders
Last active May 6, 2022 21:02
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 benders/a76cb24244746036088e2d4e2a31ba75 to your computer and use it in GitHub Desktop.
Save benders/a76cb24244746036088e2d4e2a31ba75 to your computer and use it in GitHub Desktop.
# 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