Add Homebrew's shell environment to xonsh shell on macOS/Linux
(alternative to shellenv).
If you like the idea click ⭐ on the repo and tweet. This might also accelerate adding xonsh support to Homebrew.
Homebrew has a shellenv command to add its environment to your shell: it adds a few
environment variables (HOMEBREW_ PREFIX/CELLAR/REPOSITORY) and updates a few paths (MAN/INFO/ PATH).
This xontrib automatically translates the default bash export statements of shellenv into xonsh.
To install use pip:
xpip install xontrib-homebrew
# or: xpip install -U git+https://github.com/eugenesvk/xontrib-homebrewThis xontrib will get loaded automatically for interactive sessions; to stop this, set
$XONTRIBS_AUTOLOAD_DISABLED = {"homebrew", }Add this to your xonsh run control file (~/.xonshrc or ~/.config/rc.xsh):
xontrib load homebrewSet custom Homebrew installation path via $XONTRIB_HOMEBREW_PATHBREW to /full/path/to/bin/brew if it's not installed at these default paths (which always take precedence):
| macOS | Linux |
|---|---|
/usr/local/bin/brew |
/home/linuxbrew/.linuxbrew/bin/brew |
/opt/homebrew/bin/brew |
~/.linuxbrew/bin/brew |
Set the level of verbosity via $XONTRIB_HOMEBREW_LOGLEVEL to 0–3 (default 1):
- 0 print nothing (fail silently)
- 1 print errors (e.g. can't find
brewat default locations) - 2 print warnings (e.g issues when parsing
shellenv) - 3 print more verbose messages
- Xontrib autoload currently can't be disabled due to a xonsh bug, so if you need precise control over when your environment variables are set (e.g., whether
/path/to/homebrew/binis at the top ofPATH), try installing from adeautobranch:
xpip install -U git+https://github.com/eugenesvk/xontrib-homebrew@deauto - Likely due to the same bug your
$XONTRIB_HOMEBREW_PATHBREWand$XONTRIB_HOMEBREW_LOGLEVELenv vars might be ignored in the autoloaded version, so install the@deautoversion mentioned above
This package was created with xontrib cookiecutter template.