Add conda environment info to terminal prompt : <p>(I'm using anaconda on a MacBook)<br>
By default conda adds the environment info to the comand prompt as follows:</p>

<pre><code>$ source activate my_env

(my_env) $ source deactivate

$
</code></pre>

<p>This can be switched off and on using</p>

<pre><code>conda config --set changeps1 (true|false)
</code></pre>

<p>Since my terminal prompt is already customised I'd like to add the env info in a different way, but don't know how to exactly.</p>

<p>Right now I'm using the two commands <code>sac</code>and <code>dac</code> in my .bash_profile file to activate and deactivate envs and therefore did this amateurish attempt adding <code>env_var</code>:</p>

<pre><code>env_var=""

#activate env (default env = my_env)
sac() {

    if [ -z $1 ];
    then
        ENV="my_env"
    else
        ENV="${1}"
    fi

    source activate ${ENV}

    env_var="${ENV}"
}

#deactivate env
dac() {
    source deactivate
    env_var=""
}

env_info() {
    if [[ ${env_var} == "" ]]
    then
        echo ""
    else
        echo "in ${env_var}"
    fi
}

PS1="\u "
PS1+="$(env_info) \$";
</code></pre>

<p>Which is not working (my bash knowledge is only rudimentary sorry...).
<code>env_info</code> always stays <code>""</code> no matter wether I call <code>sac</code>or <code>dac</code>in the terminal or not.</p>

<p><strong>Question1:</strong> Why is the code not working?</p>

<p><strong>Question2:</strong> Or is there maybe another way to get the current env-info in a - for this purpose - useful format?<br>
<code>conda info --envs</code> returns to much info...</p>
