Skip to content

Instantly share code, notes, and snippets.

Last active December 2, 2021 06:56
What would you like to do?
1Password to Environment Variables
#!/usr/bin/env bash
# Load environment variables from 1password
# To execute this script, execute the command below.
# source 'Name of the item'
# Signin
eval $(op signin)
# Load environment variables
SECRETS=`op get item "${ITEM_NAME}"`
ENV_VARS=$(echo $SECRETS | jq -r '[.details.sections[] as $in | $in.fields[] as $h | $in | del(.fields) as $in2 | $h * $in2][] | select(.t != "") | "\(.t)=\(.v)"')
for ENV_VAR in $ENV_VARS; do
export $(echo $ENV_VAR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment