Skip to content

Instantly share code, notes, and snippets.

@remlapmot
Last active July 22, 2025 04:09
Show Gist options
  • Save remlapmot/4ea3ac579de8f5101cef4b9e52823555 to your computer and use it in GitHub Desktop.
Save remlapmot/4ea3ac579de8f5101cef4b9e52823555 to your computer and use it in GitHub Desktop.
Update brew packages and R package for x86_64 and aarch64 and Stata on macOS
#!/usr/bin/env zsh
# Update Homebrew packages
brew upgrade --greedy
brew cleanup
# uv python install --reinstall 3.13
uv tool upgrade --all
mas upgrade
# Update packages on R Apple Silicon aarch64 arch
R -q -e 'options(repos = "https://mac.r-project.org/"); update.packages(ask = FALSE, type = "binary")'
R -q -e 'options(repos = c(personal = "https://remlapmot.r-universe.dev", universe = "https://mrcieu.r-universe.dev", CRAN = "https://cran.rstudio.com")); if (length(pkgs <- setdiff(rownames(old.packages()), "pak")) > 0) {print(pkgs); pak::pkg_install(pkgs, upgrade = TRUE, ask = FALSE)}; update.packages(type = "source")'
# R -q -e 'options(repos = c(personal = "https://remlapmot.r-universe.dev", universe = "https://mrcieu.r-universe.dev", CRAN = "https://mac.r-project.org")); if (!is.null(old.packages())) update.packages(ask = FALSE, type = "source", Ncpus = 4); remotes::update_packages()'
# Update StataMP on 10th, 20th, 30th of each month
DD=$(date +%d)
if ((${DD#0} % 10 == 0)); then
# Update Bioconductor packages and TinyTeX
# R -e 'BiocManager::install(ask = FALSE, type = "source"); tinytex::tlmgr_update()'
# Update Stata
echo -e "update query\nadoupdate, update\n" > update-stata.do
stata-mp < update-stata.do;
else
echo "It's not the 10th, 20th, or 30th of the month so Stata update query not run";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment