Skip to content

Commit 0bf01c3

Browse files
committed
Support Conda prompt prefixes
1 parent cf882dc commit 0bf01c3

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.3.0 (in development)
2+
-----------------------
3+
- Support showing Conda environment prompt prefixes
4+
15
v0.2.2 (2021-07-11)
26
-------------------
37
- When inside a `.git` directory, treat it like a bare repository, thereby

README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ it's better.
77
Features:
88

99
- lets you know if you have mail in ``$MAIL``
10-
- shows chroot and `virtualenv <https://virtualenv.pypa.io>`_ prompt prefixes
10+
- shows chroot, `virtualenv <https://virtualenv.pypa.io>`_, and `Conda
11+
<https://conda.io>`_ environment prompt prefixes
1112
- automatically truncates the current directory path if it gets too long
1213
- shows the status of the current Git repository (see below)
1314
- thoroughly documented and easily customizable

ps1.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
by running ``PS1_GIT=off`` on the command line.
5858
"""
5959

60-
__version__ = '0.2.2'
60+
__version__ = '0.3.0.dev1'
6161
__author__ = 'John T. Wodder II'
6262
__author_email__ = 'ps1@varonathe.org'
6363
__license__ = 'MIT'
@@ -267,6 +267,12 @@ def show_prompt_string(style, show_git=True):
267267
if debian_chroot:
268268
PS1 += style('[{}] '.format(debian_chroot), fg=Color.BLUE, bold=True)
269269

270+
# If a Conda environment is active, show its prompt prefix (which already
271+
# includes the parentheses and trailing space).
272+
if 'CONDA_PROMPT_MODIFIER' in os.environ:
273+
# Green like a snake!
274+
PS1 += style(os.environ['CONDA_PROMPT_MODIFIER'], fg=Color.LIGHT_GREEN)
275+
270276
# If we're inside a Python virtualenv, show the basename of the virtualenv
271277
# directory. (Note: As of virtualenv v20.0.27, we can't support custom
272278
# virtualenv prompt prefixes, as virtualenv does not export the relevant

0 commit comments

Comments
 (0)