Skip to content

Instantly share code, notes, and snippets.

@noahcrowley
Created July 25, 2024 01:07
Show Gist options
  • Save noahcrowley/bb4558fe98102262694ea8a0d012f337 to your computer and use it in GitHub Desktop.
Save noahcrowley/bb4558fe98102262694ea8a0d012f337 to your computer and use it in GitHub Desktop.
1Password Env Var Flow

Make sure you have the op command line tool installed:

brew install 1password-cli

Create a .env file that includes your environment variables and the op commands to retrieve them:

export BIG_VARIABLE=$(op item get "<Item name>" --fields <Field name> --vault <Vault name>)

Where <Item name>, <Field name>, and <Vault name> correspond the the appropriate values in 1Password.

Source the file to load the variables into your environment:

source .env

Validate that everything worked:

echo $BIG_VARIABLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment