azenv gives Azure CLI named, per-shell contexts by isolating AZURE_CONFIG_DIR per context.
It does not replace az. It only manages which Azure CLI config directory your current shell uses.
With Homebrew:
brew install lognseth/tap/azenvOr tap the repository first:
brew tap lognseth/tap
brew install azenvFor a manual install from a local checkout:
./install.shBy default this installs to ~/.local/bin/azenv.
For zsh, make sure ~/.local/bin is on your PATH:
mkdir -p ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"Add that PATH line to ~/.zshrc if it is not already there.
To install to /usr/local/bin instead:
./install.sh --systemFor zsh:
eval "$(azenv init zsh)"Put that in ~/.zshrc after installing the binary. This defines a shell function so azenv use <context> can update AZURE_CONFIG_DIR in the current terminal.
For bash:
eval "$(azenv init bash)"For fish:
azenv init fish | sourceShell completions are generated by Cobra:
azenv completion zsh > ~/.zfunc/_azenvCreate a context:
azenv create devActivate it in the current zsh terminal:
azenv use dev
echo $AZURE_CONFIG_DIR
azenv currentIf azenv use dev prints export AZURE_CONFIG_DIR=... instead of switching, load the shell integration first:
eval "$(azenv init zsh)"Create a context and log in immediately:
azenv create prod --loginOr log in later:
azenv login prodActivate it in the current terminal:
azenv use prodSet the subscription once:
az account set -s <subscription-id-or-name>Next time, just run:
azenv use prodRun azenv use with no arguments to select a context with fzf.
List contexts:
azenv lsThe active context is marked with *.
Show current context and Azure account:
azenv currentRun a single command in another context without switching the current shell:
azenv exec prod -- az account show
azenv exec staging -- terraform plan
azenv exec prod -- terraform applyClone or rename a context:
azenv clone prod prod-copy
azenv rename prod-copy sandboxLog out of a context:
azenv logout prodCheck your local setup:
azenv doctorRemove a context:
azenv rm prodBy default, contexts live here:
~/.config/azenv/
config.yaml
contexts/
prod/
azure/
metadata.yaml
Override with:
export AZENV_HOME="$HOME/.azenv"Then contexts live under:
$AZENV_HOME/
config.yaml
contexts/<name>/azure/
metadata.yaml stores friendly details such as subscription name, tenant, user, and last-used time. azenv refreshes this metadata best-effort from the Azure CLI after use and login.
azenv can print a Starship custom module config:
azenv starship initAdd the output to ~/.config/starship.toml.
A standalone program cannot directly change the parent shell environment. That is why azenv use needs the shell integration from azenv init. The wrapper evaluates the export statements emitted by the binary.
See CHANGELOG.md.
MIT. See LICENSE.