Skip to content

Instantly share code, notes, and snippets.

@lebedov
Created January 29, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lebedov/339d27eb4bab0f87f649 to your computer and use it in GitHub Desktop.
Save lebedov/339d27eb4bab0f87f649 to your computer and use it in GitHub Desktop.
Show virtualenv or conda environment in IPython prompt
# Put this in your IPython profile configuration, e.g., ~/.ipython/profile_default/ipython_config.py
import os
extra = ''
if os.environ.has_key('VIRTUAL_ENV'):
v = os.path.basename(os.environ['VIRTUAL_ENV'])
extra += '<%s> ' % v
if os.environ.has_key('CONDA_DEFAULT_ENV'):
extra += '[%s] ' % os.environ['CONDA_DEFAULT_ENV']
c.PromptManager.in_template = '%sIn [\#]: ' % extra
c.PromptManager.out_template = '%sOut[\#]: ' % extra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment