Last active
November 10, 2025 08:50
-
-
Save kidpixo/19e5961a7522f0d57529b00f3e866633 to your computer and use it in GitHub Desktop.
Update all conda enviroment, optionally using another executable like mamba and dry run option setting from cli.
This file contains hidden or 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
| # define CONDACOMMAND externally to overwrite this, I use conda or mamba | |
| # default is to use mamba, a looooot faster | |
| CONDACOMMAND=${1:-'mamba'} | |
| # DRYRUNCONDACOMMAND : is set to anything, just print the commands | |
| if [ -z $DRYRUNCONDACOMMAND ] | |
| then | |
| echo "DRYRUNCONDACOMMAND is unset, this is the real stuff" | |
| DRYRUNCONDACOMMAND='' | |
| else | |
| echo "DRYRUNCONDACOMMAND is set, this is a dry run" | |
| DRYRUNCONDACOMMAND='echo' | |
| printf "use :\n unset DRYRUNCONDACOMMAND\nto clean the variable for a real run\n" | |
| fi | |
| # # Debug | |
| # echo "CONDACOMMAND=$CONDACOMMAND" | |
| # echo "DRYRUNCONDACOMMAND=$DRYRUNCONDACOMMAND" | |
| # # print all envs | |
| # echo $(eval $($CONDACOMMAND env list) | sed '/^#/d;/^$/d' | awk '{print $1}') | |
| # # set env to base | |
| # local env=base | |
| # # run one loop cycle | |
| # $DRYRUNCONDACOMMAND $CONDACOMMAND update -n $env --all -y | |
| # list all envs , keeps only the line with path sep inside | |
| for env in $($CONDACOMMAND env list | sed -n '/\//p' | awk '{print $1}') | |
| do | |
| printf '=%.0s' {1..100} # envs separator | |
| echo | |
| echo "updating enviroment: $env" | |
| echo "--------------------------" # print current env name | |
| echo | |
| $DRYRUNCONDACOMMAND $CONDACOMMAND update -n $env --all -y # update everything | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment