-
Notifications
You must be signed in to change notification settings - Fork 1
/
cnda
executable file
·47 lines (42 loc) · 1.4 KB
/
cnda
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
#!/bin/bash
# This script initializes anaconda, if it finds an anaconda install
# Depending on what server/computer I'm on, anaconda might be installed in one of
# many possible directories. This script looks those up based on username and
# picks the first one it finds.
# The reason why I keep it out of my bashrc/zshrc is that in some scenarios,
# I actually don't want conda, or at least not by default.
# For instance, on my mac conda init takes 1 or 2 seconds, and I don't even use it
# that often. On login nodes I definitely don't want to have conda, because I want
# to be forced to set up my entire environment in a compute node.
#
# If I need conda but it's not initialized, I can always do `source cnda`
# Look for conda
usr=$(whoami)
paths=("/${HOME}/anaconda3" "/workspace/${usr}/anaconda3")
found=false
for pth in ${paths[@]}
do
if [[ -d $pth ]]
then
found=true
break
fi
done
# Initialize if found
if [[ $found ]]
then
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(\"$pth/bin/conda\" 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$pth/etc/profile.d/conda.sh" ]; then
. "$pth/etc/profile.d/conda.sh"
else
export PATH="$pth/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
fi