Setup conda env lazily when LC_LAZY_CONDA present. Add the following line to your ssh config:
Host server
HostName ssh.my-server.com
User ubuntu
+ SetEnv LC_LAZY_CONDA=1| if [[ -n "${LC_LAZY_CONDA:-}" ]]; then | |
| # Set up conda lazily when LC_LAZY_CONDA present | |
| # Need LC_ prefix, since most server `AcceptEnv LANG LC_*` | |
| CONDA_ROOT="/data/apps/miniforge3" # Adjust according to your setup | |
| conda() { | |
| unset -f conda | |
| if [[ -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]]; then | |
| . "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| else | |
| export PATH="$CONDA_ROOT/bin:$PATH" | |
| fi | |
| conda "$@" | |
| } | |
| else | |
| # >>> conda initialize >>> | |
| # !! Contents within this block are managed by 'conda init' !! | |
| __conda_setup="$('/data/apps/miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" | |
| if [ $? -eq 0 ]; then | |
| eval "$__conda_setup" | |
| else | |
| if [ -f "/data/apps/miniforge3/etc/profile.d/conda.sh" ]; then | |
| . "/data/apps/miniforge3/etc/profile.d/conda.sh" | |
| else | |
| export PATH="/data/apps/miniforge3/bin:$PATH" | |
| fi | |
| fi | |
| unset __conda_setup | |
| # <<< conda initialize <<< | |
| fi |