Last active
November 10, 2022 20:34
-
-
Save ideabucket/b9279b2063439ab3466f10af158c2afe to your computer and use it in GitHub Desktop.
Fish wrapper for brew to deactivate conda before brew {doctor,install,upgrade} and then restore environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# converted and adapted from https://stackoverflow.com/a/62179041 | |
function brew | |
set -f hooked_commands "doctor" "install" "upgrade" | |
if contains -- $argv[1] $hooked_commands | |
set -f restore_conda | |
set -f conda_envs | |
while test $CONDA_SHLVL -gt 0 | |
set -a conda_envs $CONDA_DEFAULT_ENV | |
conda deactivate | |
end | |
end | |
command brew $argv | |
set -f brew_status $status | |
if set -q restore_conda | |
for env in $conda_envs | |
conda activate "$env" | |
end | |
end | |
return $brew_status | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment