automate/020_conda.sh

55 lines
1.9 KiB
Bash

DEST=${1:-/etc/skel}
# Install our public GPG key to trusted store
# KEY_DIR=/usr/share/keyrings
KEY_DIR=/etc/apt/trusted.gpg.d
sudo curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor >conda.gpg
sudo install -o root -g root -m 644 conda.gpg ${KEY_DIR}/conda-archive-keyring.gpg
# Check whether fingerprint is correct (will output an error message otherwise)
sudo gpg --keyring ${KEY_DIR}/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806
# Add our Debian repo
sudo echo "deb [arch=amd64 signed-by=${KEY_DIR}/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | sudo tee /etc/apt/sources.list-available/conda.list
sudo ln -sf /etc/apt/sources.list-available/conda.list /etc/apt/sources.list.d/conda.list
# Install it!
sudo apt update
sudo apt install -y conda
mkdir -p "${DEST}"/.zshrc.pre-plugins.d/
cat <<-EOF | sudo tee "${DEST}"/.zshrc.pre-plugins.d/008_conda.zsh >/dev/null
# when using conda from the vim plugin it expects to be called from base conda environment.
## >>> conda initialize >>>
## !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/conda/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
. "/opt/conda/etc/profile.d/conda.sh"
else
export PATH="/opt/conda/bin:$PATH"
fi
fi
unset __conda_setup
## <<< conda initialize <<<
# switch to the default conda environment when leaving a condaenv
AUTOSWITCH_DEFAULT_CONDAENV="base"
# AUTOSWITCH_SILENT
EOF
# We add autoswitching for conda by adding the following to .zgen-local-plugins:
# zgenom load bckim92/zsh-autoswitch-conda
# see 020_zsh_quickstart.sh
# see: https://github.com/ubaldot/vim-conda-activate for vim support
# Check to see if the installation is successful:
. /opt/conda/etc/profile.d/conda.sh
conda -V