envr is a self-contained cross-platform script (envr.ps1) that allows developers to specify environment variables, aliases, and additions to the system path.
envr can be used with bash, zsh, and PowerShell in Linux, Windows, and MacOS. See the github workflows for more information on the shells that are tested.
- Activate the environment:
. ./envr.ps1- You can alias
envrto. ./envr.ps1in your shell profile for convenience
- You can alias
- Deactivate the environment:
unsource - Upgrade to the latest version:
wget -O envr.ps1 https://github.com/JPHutchins/envr/releases/latest/download/envr.ps1 - Verify the integrity of your copy of
envr:Windows users may compare the SHA256s manually:wget -O - https://github.com/JPHutchins/envr/releases/latest/download/sha256.sum | shasum --check(Invoke-WebRequest https://github.com/JPHutchins/envr/releases/latest/download/sha256.sum).RawContent (Get-FileHash -Path envr.ps1 -Algorithm SHA256).hash
- Verify the authenticity of your copy of
envrwith cosign:Note: you must install cosign.
wget envr.ps1 https://github.com/JPHutchins/envr/releases/latest/download/envr.ps1.cosign.bundle cosign verify-blob envr.ps1 --bundle envr.ps1.cosign.bundle --certificate-identity https://github.com/JPHutchins/envr/.github/workflows/release.yml@refs/tags/0.5.7 --certificate-oidc-issuer https://token.actions.githubusercontent.com rm envr.ps1.cosign.bundleNote: the section
release.yml@refs/tags/<TAG>must be updated with the version that you are verifying.
- Download and commit
envr.ps1to the root of your repository. This routine is also a good way to upgrade yourenvr.ps1to the latest version.- Linux/Mac/Windows using
wget:wget -O envr.ps1 https://github.com/JPHutchins/envr/releases/latest/download/envr.ps1 - Windows without
wget:Invoke-WebRequest -OutFile envr.ps1 -Uri https://github.com/JPHutchins/envr/releases/latest/download/envr.ps1
- Linux/Mac/Windows using
- Create, define and commit
envr-defaultto the root of your repository. - Modify your
.gitignoreto ignoreenvr-local.
envr-default (and envr-local) is a INI/TOML-ish text file of the following shape. Currently four categories are supported, marked by [ ]. Definitions are in the format KEY=VALUE.
Note: inline comments are not supported
[PROJECT_OPTIONS]
# This sets the environment variable ENVR_PROJECT_NAME for use by the environment
PROJECT_NAME=coolrepo
# If you have a python venv, envr can activate it along with the envr environment
PYTHON_VENV=venv
[VARIABLES]
FOO=bar
ANSWER=42
PLUGINS=~/chuck/ext/plugins
# Environment variables can use other environment variables
PATH_SNOOPY_TOOL=$PLUGINS/x86/v436.874/snoopy-ext/bin
[ADD_TO_PATH]
# Here, the key "TOOLCHAIN_PATH" is not exported to PATH but rather
# it is used internally to keep track of modifications to PATH
TOOLCHAIN_PATH=/opt/supercollider/system/arm32/bin
# ENVR_ROOT is an environment variable set by envr
# It is the full path to envr.ps1 (the root of your repo)
BINARIES=$ENVR_ROOT/build/bin
[ALIASES]
build=cmake -GNinja -Bbuild -DBOARD=hrv43 -DCMAKE_BUILD_TYPE=Debug -DLOG_LEVEL=INFO && cmake --build build
flash=cmake -GNinja -Bbuild -DBOARD=hrv43 -DCMAKE_BUILD_TYPE=Debug -DLOG_LEVEL=INFO && cmake --build build --target flash-
. ./envr.ps1from the root of your repository. -
envr always reads
envr-defaultfirst, followed byenvr-localif it exists.envr-localis used to provide the necessary local modifications to environment variables, paths, and aliases.envr-defaultkeys that are not overwritten byenvr-localwill be available as they were defined inenvr-default. Users can add keys to theirenvr-local, though it would often be preferred to updateenvr-defaultas well so that everyone can be benefit from the definitions.
unsource
envr does not need to be installed, but it can be nice to add the alias envr
to your shell profile, allowing you to activate the environment of the current
directory with envr instead of . ./envr.ps1.
Add-Content -Path $profile -Value "function envr { . ./envr.ps1 }"echo "alias envr='. ./envr.ps1'" >> ~/.bashrcecho "alias envr='. ./envr.ps1'" >> ~/.zshrc#$&*%^
Because PowerShell scripts don't run with any other extension.
The goal of envr is to unify the development environment setup of any repository by providing a consistent interface for Windows, MacOS, and GNU/Linux shells.
git clone git@github.com:JPHutchins/envr.git
cd envr
git checkout develop
git checkout -b feature/my-feature-branch-name
- Tests are run from this repository root.
- Windows PS:
.\tests\windows\ps.ps1 - Windows WSL bash:
bash tests/sh/bash.sh - Windows WSL bash with zsh installed:
bash tests/sh/zsh.sh - Linux/macOS bash:
tests/sh/bash.sh - Linux/macOS zsh:
tests/sh/zsh.sh - Linux/macOS all shells:
tests/sh/all.shrecommended to verifybashzshcompatibility.
- Windows PS:
- Add tests for any new shell, feature, or compatibility update.