Skip to content

Environment variables

Open in ChatGPT ↗
Ask ChatGPT about this page
Open in Claude ↗
Ask Claude about this page
Copied!

Save or sync environment variables to load into your terminal sessions.

Environment variables in Warp are similar to .env files, except you can:

  • Load them into your terminal session with a click.
  • Use them in parameterized workflows.
  • Dynamically reference secrets from external managers.

How to create and edit environment variables

Section titled “How to create and edit environment variables”

You can create new environment variables through:

Any of these entry points will open the environment variables editor where you can name and describe your environment variables.

Environment variable editor in Warp Drive showing fields for name and description.

Warp supports two types of environment variables: static variables and dynamic variables.

Static variables are similar to .env files. You create the variables by entering raw strings of text. Each variable has a variable name and a corresponding value.

Saving a static environment variable with name and value pairs.

After you save the environment variable, you can click it to load it into your terminal session.

Loading a saved static environment variable into the current terminal session.

When you use static variables, Warp stores them securely in Warp Drive.

Note: Static variables should not be used to replace a secret manager. Please use dynamic variables for any sensitive information.

Dynamic variables let you reference secrets that are stored securely outside of Warp in external secret managers, such as 1Password or LastPass.

You can use custom commands to create dynamic variables for any system with a public API or CLI, such as AWS or Hashicorp Vault.

How to create and edit dynamic environment variables

Section titled “How to create and edit dynamic environment variables”

To create a new dynamic variable:

  1. Open the environment variable editor.
  2. Use the key icon to reveal the dynamic variable menu.
  3. Select an integrated password manager or “Command” to write your own custom integration.

Opening the dynamic environment variable menu via the key icon in the editor.

Before you get started, please ensure you have the CLI installed for your tool of choice and follow the instructions to enable the CLI:

Then, you can click the key icon and select your manager from the dropdown menu.

Selecting an integrated password manager from the dynamic variable dropdown.

The CLI will require you to authenticate and then provide you with a list of available secrets.

Selecting a secret name from the password manager CLI's available list of secrets.

Reference the documentation for your external secret manager. Then, write a custom command to retrieve secrets.

For example, you can write a command using the Hashicorp Vault CLI to retrieve and load the password field for the staging server. When using secret commands, Warp stores the command but never the actual secrets. The secrets are referenced and loaded into a terminal session at runtime.

// vault kv get -field=password secret/staging/app/server/creds

Custom command using the Hashicorp Vault CLI to retrieve a password field at runtime.

There are three ways to invoke your environment variables and load them into a terminal session:

  1. Click to load into a current section
  2. Click to load into a subshell
  3. Select to load in with a workflow

First, click your environment variable from Warp Drive or the Command Palette.

Then, review the confirmation block. If your environment variables are correct, hit enter to load them into your session.

Confirmation block prompting to load environment variables into the current session.

Environment variables successfully loaded into the current terminal session.

These environment variables will now be present for the remainder of your session.

To load environment variables into a subshell, you will need to open Warp Drive and locate your environment variable in the Warp Drive index. You can then use the overflow menu to select “Load in subshell.”

Loading an environment into a subshell reduces the risk of your environment variables accidentally contaminating your workspace. The subshell is clearly defined and once you exit it, any environment variables set by Warp Environment Variables will be cleared, unless they are already present in the parent session.

Selecting Load in subshell from an environment variable's overflow menu in Warp Drive.

Environment variables loaded into a subshell, isolated from the parent terminal session.

Any time you run a workflow, you can select from existing environment variables. This allows you to dynamically inject environment variables into a parameterized workflow so you can use a single workflow command in multiple environments, such as production and staging.

For example, you may have a workflow to create a new team that uses the environment variable $SERVER_URL. By using the environment variables dropdown in the workflow card, you can dynamically inject the necessary variables. This ensures the workflow references the appropriate values so the command runs with the relevant environment-specific information.

These environment variables will now be present for the remainder of your session until you clear them or overwrite them with a different environment.

Selecting environment variables from the dropdown when running a parameterized workflow.

Import and export environment variables in Warp Drive

Section titled “Import and export environment variables in Warp Drive”

Please see our Warp Drive Import and Export instructions.