title: Conda 4.7 how to activate env in bash script
body: <p>I can activate my env in my shell</p>
  
  <pre><code>&gt; conda activate env
  </code></pre>
  
  <p>When I'm in a bash script, I can check the version of my conda but I can't activate my env</p>
  
  <pre><code>#!/bin/bash
  
  conda --version
  &gt; conda 4.7.12
  
  conda activate env
  &gt; CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
  To initialize your shell, run
  
      $ conda init &lt;SHELL_NAME&gt;
  
  Currently supported shells are:
    - bash
    - fish
    - tcsh
    - xonsh
    - zsh
    - powershell
  
  See 'conda init --help' for more information and options.
  
  IMPORTANT: You may need to close and restart your shell after running 'conda init'.
  </code></pre>
  
  <p>Here is my <code>.bashrc</code> about conda initialization</p>
  
  <pre><code>  8 # User specific aliases and functions
    9 
   10 # &gt;&gt;&gt; conda initialize &gt;&gt;&gt;
   11 # !! Contents within this block are managed by 'conda init' !!
   12 __conda_setup="$('/work/***/miniconda3/bin/conda' 'shell.bash' 'hook' 2&gt; /dev/null)"
   13 if [ $? -eq 0 ]; then
   14     eval "$__conda_setup"
   15 else
   16     if [ -f "/work/***/miniconda3/etc/profile.d/conda.sh" ]; then
   17         . "/work/***/miniconda3/etc/profile.d/conda.sh"
   18     else
   19         export PATH="/work/***/miniconda3/bin:$PATH"
   20     fi
   21 fi
   22 unset __conda_setup
   23 # &lt;&lt;&lt; conda initialize &lt;&lt;&lt;
  </code></pre>
  
  <p>I found from here : <a href="https://stackoverflow.com/questions/52779016/conda-command-working-in-command-prompt-but-not-in-bash-script">Conda command working in command prompt but not in bash script</a> that I can add in my bash script before activate my env :</p>
  
  <pre><code>source /work/***/miniconda3/etc/profile.d/conda.sh
  </code></pre>
  
  <p>And it works (my env is activated) but I don't want to add this line at the begginning of all my bash scripts since I already have it in my <code>.bashrc</code>. I also found from here : <a href="https://stackoverflow.com/questions/55507519/python-activate-conda-env-through-shell-script">Python - Activate conda env through shell script</a> that I can source my <code>.bashrc</code> when I run my script with</p>
  
  <pre><code>bash -i shell_script.sh
  </code></pre>
  
  <p>It is also working (my env is activated). </p>
  
  <p>How can I source automatically my <code>.bashrc</code> each time I run a script without adding a line in each script and without adding <code>-i</code> ? Can I do this with my <code>.bashrc_profile</code> for example ?</p>