-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_install_conda.sh
72 lines (61 loc) · 1.79 KB
/
user_install_conda.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -eu
function get_latest_anaconda {
wget $ANACONDA_BASE_URL -o wget.err -O- \
| grep Anaconda3 | grep Linux-x86_64 \
| sort \
| tail -n 1 \
| perl -ne 'print $1 if m/">(Anaconda3.*)<\/a/'
}
ANACONDA_BASE_URL=https://repo.continuum.io/archive
ANACONDA_URL=$ANACONDA_BASE_URL/$(get_latest_anaconda)
MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
CONDA_URL=$ANACONDA_URL
WHICH_CONDA=$(basename $CONDA_URL)
BASH_RC=$HOME/.bashrc
BASH_RC_CONDA=${BASH_RC}_conda
BASH_ALIASES=$HOME/.bash_aliases
BASH_ALIASES_CONDA=${BASH_ALIASES}_conda
function install_conda {
CONDA_DEST=~/$WHICH_CONDA
if [[ ! -f $CONDA_DEST ]]; then
wget $CONDA_URL -O $CONDA_DEST
fi
bash $CONDA_DEST -b
# get prefix
source <(grep -m 1 ^PREFIX= $CONDA_DEST --binary-files=text)
echo "
# added by Anaconda3/Miniconda3 installer
export PATH=\"$PREFIX/bin:\$PATH\"" >>$BASH_RC
# set up for some other stuff
$PREFIX/bin/conda install pandoc --yes
cat >> $BASH_RC_CONDA <<EOF
# user_install_conda.sh
function shell_view_rst {
pandoc \$1 | lynx -stdin
}
function shell_view_md {
man <(rst2man.py \$1)
}
EOF
cat >> $BASH_RC <<EOF
# user_install_conda.sh
source $BASH_RC_CONDA
EOF
cat >> $BASH_ALIASES_CONDA <<EOF
# user_install_conda.sh
alias conda-get-latest='conda env list | grep \"^anaconda-[0-9]\{8\}\" | cut -d\" \" -f1 | sort | tail -n 1'
alias conda-create-latest='conda create --name anaconda-\$(date +%Y%m%d) anaconda'
alias conda-clone-latest='conda create --clone \$(conda-get-latest) --name'
alias sactivate-latest='source activate \$(conda-get-latest)'
alias sactivate='source activate'
alias sdeactivate='source deactivate'
EOF
cat >> $BASH_ALIASES <<EOF
# user_install_conda.sh
source $BASH_ALIASES_CONDA
EOF
}
if [ -z $(which conda) ]; then
install_conda
fi