don't display activating information if already active

This commit is contained in:
2017-01-21 21:56:51 -05:00
parent 28b461f45b
commit 0df174e2d1
+9 -4
View File
@@ -173,10 +173,12 @@ def activate_virtualenv(source=True):
def do_activate_virtualenv(bare=False):
"""Executes the activate virtualenv functionality."""
if not bare:
click.echo('To activate this project\'s virtualenv, run the following:\n $ {0}'.format(crayons.red('pipenv shell')))
else:
click.echo(activate_virtualenv())
# Check for environment marker, and skip if it's set.
if not 'PIPENV_ACTIVE' in os.environ:
if not bare:
click.echo('To activate this project\'s virtualenv, run the following:\n $ {0}'.format(crayons.red('pipenv shell')))
else:
click.echo(activate_virtualenv())
def do_purge(bare=False, allow_global=False):
@@ -356,6 +358,9 @@ def shell():
# Ensure that virtualenv is available.
ensure_project()
# Set an environment viariable, so we know we're in the environment.
os.environ['PIPENV_ACTIVE'] = '1'
# Spawn the Python process, and iteract with it.
shell = os.environ['SHELL']
click.echo(crayons.yellow('Spawning virtualenv shell ({0}).'.format(crayons.red(shell))))