From db3624244a0247af75b5d9474816d3f98a7b2624 Mon Sep 17 00:00:00 2001 From: Martinez Date: Thu, 7 Jan 2016 16:32:33 +0100 Subject: [PATCH] add WineprefixPart minor cleanup --- libexec/render.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/libexec/render.py b/libexec/render.py index 1e979b3..541ccb3 100755 --- a/libexec/render.py +++ b/libexec/render.py @@ -39,6 +39,7 @@ COLOR_GIT_STAGED = 10 COLOR_PROMPT_OK = 14 COLOR_PROMPT_ERROR = 1 +COLOR_OK = 10 COLOR_ERROR = 196 MOUNT_IGNORE_FS = ["iso9660", "tmpfs", "rootfs"] @@ -327,10 +328,42 @@ class VirtualEnvPart(Part): if virtualenv: self.fragments.append("⬢ ") - self.fragments.append(style_color(COLOR_GIT_CLEAN)) + self.fragments.append(style_color(COLOR_OK)) self.fragments.append(virtualenv) self.fragments.append(style_reset()) +class WineprefixPart(Part): + """ + ♿ name:[32|64] + + Displays the current WINEPREFIX (iff set) basename and x86 subarchitecture (32 or 64). + + The basename is green if the directory exists, red otherwise. + """ + + def __init__(self): + Part.__init__(self) + + wineprefix = os.getenv("WINEPREFIX") + arch = os.getenv("WINEARCH") + + if wineprefix: + self.fragments.append("♿ ") + + self.fragments.append(style_color(COLOR_OK if os.path.isdir(wineprefix) else COLOR_ERROR)) + self.fragments.append(os.path.basename(wineprefix)) + self.fragments.append(style_reset()) + + if arch == "win32": + self.fragments.append(":32") + elif arch: + self.fragments.append(":") + self.fragments.append(style_color(COLOR_ERROR)) + self.fragments.append("?") + self.fragments.append(style_reset()) + else: + self.fragments.append(":64") + class GitPart(Part): """ ↘2 ↗4 ⚠master ?11 ✎6 ✉10 @@ -557,10 +590,11 @@ if __name__ == "__main__": pp = PathPart(settings) gp = GitPart() vp = VirtualEnvPart() + wp = WineprefixPart() pad = Padding(settings.term_width) sp = StatsPart(settings, sysload) - line = [lp, pp, gp, vp, pad, sp] + line = [lp, pp, gp, vp, wp, pad, sp] pp.shrink_fit(line) pad.expand_fit(line)