# Setting environment variables

An environment variable is a variable set outside of a program: it is then available to shell commands, Python or R scripts, etc. The benefit of using such variables is that they allow the same code to work in different environments: if BLab share is mounted to Z:\ on one machine, Y:\ on another, and `/Volumes/Fas-Phyc-PEB-Lab` on yet another one, a program can use the value of the `BLAB_SHARE_PATH` environment variable set on each machine to Z:\\, Y:\\, and /Volumes/Fas-Phyc-PEB-Lab respectively.

## On MacOS

The instructions will depend on which shell you are using (run `ps -p $$` and look at the CMD column in the output if unsure). For bash, edit `~/.bash_profile`, for zsh, edit `~/.zprofile`. In both cases, add the following line to set `BLAB_SHARE_PATH` to `/Volumes/Fas-Phyc-PEB-Lab`

```
export BLAB_SHARE_PATH=/Volumes/Fas-Phyc-PEB-Lab
```

## On Windows

1. Click on the Start button.
2. Start typing "environment".
3. Select "Edit environment variables for your account" (or something similar, just not something with "the system").
4. Click "New"/"Add".
5. To set `BLAB_SHARE_PATH` to `Z:\`, use `BLAB_SHARE_PATH` as the name and `Z:\` as the value.

## For a terminal session

Run the following command to set `BLAB_SHARE_PATH` to `/Volumes/Fas-Phyc-PEB-Lab`

```
$ export BLAB_SHARE_PATH=/Volumes/Fas-Phyc-PEB-Lab
```

## For a single command

To run a python script called `foo.py` that resides in the current directory, temporarily setting the environment variable `BLAB_SHARE_PATH` to `Volumns/Fas-Phyc-PEB-Lab`, run

```
$ BLAB_SHARE_PATH=/Volumes/pn-schmopus python foo.py
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.bergelsonlab.com/programming-info/quick-programming-computing-how-tos/setting-environment-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
