Skip to content

Commit

Permalink
Move and robustify miniconda setup
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf committed Oct 30, 2024
1 parent f29792d commit 91d02c9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
46 changes: 34 additions & 12 deletions dot_local/share/zinit/plugins/personal/personal.plugin.zsh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 <FILE 1> <FILE 2>"
echo "USAGE: ediff <FILE 1> <FILE 2>"
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
}

Expand Down Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions dot_zshrc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions run_once_before_install-packages-darwin.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ cask "iterm2"
cask "keepassxc"
cask "macfuse"
cask "mactex"
cask "miniconda"
cask "musicbrainz-picard"
cask "paraview"
cask "slack"
Expand Down

0 comments on commit 91d02c9

Please sign in to comment.