From 10388217e6a1623bf7dacd3d889d9be723abc096 Mon Sep 17 00:00:00 2001 From: Martinez Date: Mon, 4 Jan 2016 11:25:14 +0100 Subject: [PATCH] add VirtualEnvPart --- libexec/render.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libexec/render.py b/libexec/render.py index 8b41087..968d85f 100755 --- a/libexec/render.py +++ b/libexec/render.py @@ -316,6 +316,24 @@ def command(cmd): return s.stdout.read().decode("utf-8") +class VirtualEnvPart(Part): + """ + ⬢ path + + Displays the current python virtualenv's path iff set. + """ + + def __init__(self): + Part.__init__(self) + + virtualenv = os.getenv("VIRTUAL_ENV") + + if virtualenv: + self.fragments.append("⬢ ") + self.fragments.append(style_color(COLOR_GIT_CLEAN)) + self.fragments.append(virtualenv) + self.fragments.append(style_reset()) + class GitPart(Part): """ ↘2 ↗4 ⚠master ?11 ✎6 ✉10 @@ -541,10 +559,11 @@ if __name__ == "__main__": lp = LoginPart(settings, sysload) pp = PathPart(settings) gp = GitPart() + vp = VirtualEnvPart() pad = Padding(settings.term_width) sp = StatsPart(settings, sysload) - line = [lp, pp, gp, pad, sp] + line = [lp, pp, gp, vp, pad, sp] pp.shrink_fit(line) pad.expand_fit(line)