add VirtualEnvPart

This commit is contained in:
Martinez 2016-01-04 11:25:14 +01:00
parent 63210a3f4d
commit 10388217e6

View file

@ -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)