Skip to content

Instantly share code, notes, and snippets.

@dschaehi
Last active October 28, 2024 15:06
Show Gist options
  • Save dschaehi/4067ff5538786a8754e8fd631c72b711 to your computer and use it in GitHub Desktop.
Save dschaehi/4067ff5538786a8754e8fd631c72b711 to your computer and use it in GitHub Desktop.
A script for updating all conda-forge environments
#!/usr/bin/env sh
comment_box() {
msg="$1"
msg_length=${#msg}
border_width=$((msg_length + 4)) # Padding for spaces around message
# Generate the top and bottom border using the chosen comment character
border=$(printf '%*s' "$border_width" '') # Create empty string of width
border=$(echo "$border" | tr ' ' '#') # Replace spaces with '#'
echo "$border"
echo "# $msg #"
echo "$border"
}
for var in $(conda env list --json | jq -r '.envs[] | select(contains("/miniforge3/")) | split("/")[-1]')
do
echo
comment_box "Update conda environment \"$var\""
conda update -n $var --all -y -q
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment