From 91d02c91be0e87a3259f786444d21bcec3fa3308 Mon Sep 17 00:00:00 2001 From: Marc Henry de Frahan Date: Wed, 30 Oct 2024 15:21:03 -0600 Subject: [PATCH] Move and robustify miniconda setup --- .../plugins/personal/personal.plugin.zsh.tmpl | 46 ++++++++++++++----- dot_zshrc.tmpl | 23 ---------- ...nce_before_install-packages-darwin.sh.tmpl | 1 + 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl b/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl index a569bd3..5500032 100644 --- a/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl +++ b/dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl @@ -85,19 +85,10 @@ function recd() { cd `pwd`; } # From: https://defunitive.wordpress.com/2011/07/23/invoking-emacs-ediff-from-the-command-line/ function ediff() { if [ "X${2}" = "X" ]; then - echo "USAGE: ediff " + echo "USAGE: ediff " else - # The --eval flag takes lisp code and evaluates it with emacs - "$EMACS_PLUGIN_LAUNCHER" -nw --eval "(ediff-files \"$1\" \"$2\")" - fi -} - -# Load spack environment if you want it. I do this instead of loading -# it by default because it would slow down terminal startup time -function load_spack(){ - if [ -d "$SPACK_DIR" ]; then - export SPACK_ROOT=${SPACK_DIR} - . ${SPACK_ROOT}/share/spack/setup-env.sh + # The --eval flag takes lisp code and evaluates it with emacs + "$EMACS_PLUGIN_LAUNCHER" -nw --eval "(ediff-files \"$1\" \"$2\")" fi } @@ -136,6 +127,37 @@ multitb() ( return "${exit_code}" ) +function conda-start(){ + CONDA_EXEC="" + CONDA_DIR="" + if [[ -x "$(command -v conda)" ]]; then + CONDA_DIR="$(conda info --base)" + CONDA_EXEC="conda" + elif [ -d "${HOME}/miniconda3" ]; then + CONDA_DIR="${HOME}/miniconda3" + CONDA_EXEC="${CONDA_DIR}/conda" + fi + + if [ -d "${CONDA_DIR}" ]; then + # >>> conda initialize >>> + __conda_setup="$('${CONDA_EXEC}' 'shell.zsh' 'hook' 2> /dev/null)" + if [ $? -eq 0 ]; then + eval "$__conda_setup" + else + if [ -f "${CONDA_DIR}/etc/profile.d/conda.sh" ]; then + . "${CONDA_DIR}/etc/profile.d/conda.sh" + else + export PATH="${CONDA_DIR}/bin:$PATH" + fi + fi + unset __conda_setup + # <<< conda initialize <<< + fi + + unset CONDA_DIR + unset CONDA_EXEC +} + {{- if eq .chezmoi.os "darwin" }} # iTerm2 window/tab color commands # Requires iTerm2 >= Build 1.0.0.20110804 diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 952aeb6..ad49563 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -37,29 +37,6 @@ fi export PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" -# miniconda -MINICONDA_DIR="${HOME}/miniconda3" -if [ -d "${MINICONDA_DIR}" ]; then - # >>> conda initialize >>> - __conda_setup="$('${MINICONDA_DIR}/conda' 'shell.zsh' 'hook' 2> /dev/null)" - if [ $? -eq 0 ]; then - eval "$__conda_setup" - else - if [ -f "${MINICONDA_DIR}/etc/profile.d/conda.sh" ]; then - . "${MINICONDA_DIR}/etc/profile.d/conda.sh" - else - export PATH="${MINICONDA_DIR}/bin:$PATH" - fi - fi - unset __conda_setup - # <<< conda initialize <<< -fi - -# Spack home directory -if [ -d "${HOME}/spack" ]; then - export SPACK_DIR="${HOME}/spack" -fi - # combustion directory export COMBUSTION_DIR="${HOME}/combustion" export MASA_HOME="${COMBUSTION_DIR}/install/MASA" diff --git a/run_once_before_install-packages-darwin.sh.tmpl b/run_once_before_install-packages-darwin.sh.tmpl index d260b61..cc6972a 100644 --- a/run_once_before_install-packages-darwin.sh.tmpl +++ b/run_once_before_install-packages-darwin.sh.tmpl @@ -97,6 +97,7 @@ cask "iterm2" cask "keepassxc" cask "macfuse" cask "mactex" +cask "miniconda" cask "musicbrainz-picard" cask "paraview" cask "slack"