Skip to content

Instantly share code, notes, and snippets.

@ideabucket
Last active November 10, 2022 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideabucket/b9279b2063439ab3466f10af158c2afe to your computer and use it in GitHub Desktop.
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
# 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