From 0df174e2d13dc96e67b41cbd16a40e67597f00a3 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 21 Jan 2017 21:56:51 -0500 Subject: [PATCH] don't display activating information if already active --- pipenv/cli.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 694af212..7e99b30e 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -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))))