Skip to content

Terminal environment (bashrc.yml)

Before Dline runs a command, it reads .agents/bashrc.yml in the workspace root. The file prepares environment variables, loads startup scripts, and runs the commands you specify before and after each command. Typical uses are activating a Python virtual environment, loading the Visual Studio developer environment (vcvars64.bat), and setting proxy or toolchain paths.

Select the scale icon in the toolbar below the input box (tooltip Manage Dline Rules & Workflows) and switch to the Environments tab:

  1. Pick a workspace in Workspace (a multi-root workspace lists several).
  2. Pick the terminal profile to configure in Terminal Profile. It defaults to Default Terminal Profile from settings.
  3. Edit the three sub-tabs:
    • Environment: add environment variables. Check Unset to remove the variable from the command environment.
    • Startup Scripts: add startup script paths.
    • Commands: choose a Python Env Manager (None, Conda, or venv) and edit Pre Commands and Post Command.
  4. Changes are saved to .agents/bashrc.yml about 0.35 seconds after you stop typing; the status shows Saving… and then Saved. When you edit the file directly, the panel picks up the change within about a second and shows Synced.

The panel only updates the selected terminal profile for the current platform; other platforms and profiles stay unchanged. If the file was changed externally before a save, the save is rejected so the external edit is not overwritten; reload and edit again.

The Environments tab of the capabilities panel: the Workspace and Terminal Profile selects, the Environment, Startup Scripts, and Commands sub-tabs, and the Add variable buttonThe Environments tab of the capabilities panel: the Workspace and Terminal Profile selects, the Environment, Startup Scripts, and Commands sub-tabs, and the Add variable button

Adding the variable API_BASE_URL on the Environment sub-tab with the value http://localhost; after typing stops the status shows SavedAdding the variable API_BASE_URL on the Environment sub-tab with the value http://localhost; after typing stops the status shows Saved

  • Conda lists the Conda environments on your machine and adds conda activate <name> as a pre command.
  • venv defaults to ${workspaceFolder}/.venv (${workspaceFolder}\.venv on Windows) and generates the activation command for your terminal:
    • bash, zsh, and similar: . '<path>/bin/activate'
    • Command Prompt: call "<path>\Scripts\activate.bat"
    • PowerShell: & "<path>\Scripts\Activate.ps1"
version: 1
environment:
PIP_INDEX_URL: https://mirrors.example.com/pypi/simple
platforms:
win32:
environment:
PYTHONUTF8: "1"
profiles:
default:
environment:
TOOLCHAIN_HOME: ${workspaceFolder}\tools
LEGACY_FLAG: null
startupScripts:
- C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
preCommands:
- '& "${workspaceFolder}\.venv\Scripts\Activate.ps1"'
postCommand: Write-Output done
linux:
profiles:
bash:
startupScripts:
- ./scripts/dev-env.sh
preCommands:
- conda activate myenv
FieldDescription
versionRequired and must be 1
environmentEnvironment variables shared by every platform
platforms.<platform>The platform name must be win32, linux, or darwin
platforms.<platform>.environmentEnvironment variables for that platform
platforms.<platform>.profiles.<profile ID>Settings for one terminal profile, which can contain the four fields below
environmentEnvironment variables for that profile. Values can be strings, numbers, or booleans; null removes the variable
startupScriptsA list of startup script paths
preCommandsA list of commands run before every command
postCommandOne command run after every command
  • An unlisted field, an unknown platform name, or a value of the wrong type makes the whole file invalid. Dline logs the error and runs the command without any project configuration.
  • The three levels of environment variables are merged in the order shared, platform, profile; later levels override earlier ones.
PlatformAvailable IDs
Windowsdefault (Windows PowerShell), powershell-7, powershell-legacy, cmd, wsl-bash, git-bash
macOSdefault (zsh), zsh, bash
Linuxdefault (bash), bash, zsh, dash

default is first resolved to a concrete profile for the platform (powershell on Windows, zsh on macOS, bash on Linux); if no entry exists for that ID, Dline looks up default itself. The profile Dline uses is set by Default Terminal Profile in Settings → Terminal.

The values of environment, startupScripts, preCommands, and postCommand can use:

  • ${workspaceFolder}: the root of the workspace that contains the command;
  • ${env:NAME}: the value of the environment variable NAME in the Dline process, or an empty string if it is not set.

Relative startup script paths are resolved against the workspace root.

  • Startup scripts: in a VS Code terminal they are loaded once, when the terminal is created; background commands load them before every command. Supported script types depend on the terminal:

    • PowerShell: .ps1, plus .bat / .cmd (environment variables set by the script are carried back into PowerShell);
    • Command Prompt: .bat, .cmd;
    • bash, zsh, and similar: .bashrc, .bash, .sh.

    A script of an unsupported type is not run and is recorded as a failure.

  • Pre commands run before every command and the post command runs after it. Their output is discarded.

  • A failing startup script, pre command, or post command does not stop your command; the failure is written to the Dline log with the [ShellEnvironment] prefix.

  • The exit code is always the exit code of your command, regardless of the post command.

  • The configuration only applies to commands inside a workspace. In a multi-root workspace, the .agents/bashrc.yml of the workspace that contains the command’s directory is used.