add WineprefixPart
minor cleanup
This commit is contained in:
parent
dd9c000ec5
commit
db3624244a
1 changed files with 36 additions and 2 deletions
|
@ -39,6 +39,7 @@ COLOR_GIT_STAGED = 10
|
||||||
COLOR_PROMPT_OK = 14
|
COLOR_PROMPT_OK = 14
|
||||||
COLOR_PROMPT_ERROR = 1
|
COLOR_PROMPT_ERROR = 1
|
||||||
|
|
||||||
|
COLOR_OK = 10
|
||||||
COLOR_ERROR = 196
|
COLOR_ERROR = 196
|
||||||
|
|
||||||
MOUNT_IGNORE_FS = ["iso9660", "tmpfs", "rootfs"]
|
MOUNT_IGNORE_FS = ["iso9660", "tmpfs", "rootfs"]
|
||||||
|
@ -327,10 +328,42 @@ class VirtualEnvPart(Part):
|
||||||
|
|
||||||
if virtualenv:
|
if virtualenv:
|
||||||
self.fragments.append("⬢ ")
|
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(virtualenv)
|
||||||
self.fragments.append(style_reset())
|
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):
|
class GitPart(Part):
|
||||||
"""
|
"""
|
||||||
↘2 ↗4 ⚠master ?11 ✎6 ✉10
|
↘2 ↗4 ⚠master ?11 ✎6 ✉10
|
||||||
|
@ -557,10 +590,11 @@ if __name__ == "__main__":
|
||||||
pp = PathPart(settings)
|
pp = PathPart(settings)
|
||||||
gp = GitPart()
|
gp = GitPart()
|
||||||
vp = VirtualEnvPart()
|
vp = VirtualEnvPart()
|
||||||
|
wp = WineprefixPart()
|
||||||
pad = Padding(settings.term_width)
|
pad = Padding(settings.term_width)
|
||||||
sp = StatsPart(settings, sysload)
|
sp = StatsPart(settings, sysload)
|
||||||
|
|
||||||
line = [lp, pp, gp, vp, pad, sp]
|
line = [lp, pp, gp, vp, wp, pad, sp]
|
||||||
|
|
||||||
pp.shrink_fit(line)
|
pp.shrink_fit(line)
|
||||||
pad.expand_fit(line)
|
pad.expand_fit(line)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue