From c90676c1d02a1820445762e62d3ad1f24e93ddb1 Mon Sep 17 00:00:00 2001 From: q Date: Mon, 17 Mar 2025 12:23:59 +0200 Subject: [PATCH] teplater --- shell/qaskpass | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/shell/qaskpass b/shell/qaskpass index d54e9b3..27f8309 100755 --- a/shell/qaskpass +++ b/shell/qaskpass @@ -10,7 +10,7 @@ import sys import termios import tty -__version__ = "20250311.a" +__version__ = "20250317.a" class bc: @@ -37,6 +37,10 @@ class bc: setattr(self, x, "") setattr(self, "bold", "") + def format(self, s): + format_dict = {x: getattr(self, x) for x in "rgbcmyzkRGBCMY"} + return s.format(**format_dict) + class QAsk: def __init__(self): @@ -54,7 +58,13 @@ class QAsk: epilog="Dialog printed to stderr, user input echoed to stdout, i.e. input=$( qaskpass )", ) - parser.add_argument("--title", "-t", action="store", default=None, help="Title for dialog") + parser.add_argument( + "--title", + "-t", + action="store", + default=None, + help="Title for dialog. Use {G} to change color to bright green. Valid codes: rgbcmyzkRGBCMY", + ) parser.add_argument( "-w", action="store", type=int, default=5, help="Width of display area. 0 to disable display." ) @@ -148,7 +158,8 @@ class QAsk: print(self.c.noblink, file=sys.stderr, end="") self.dot = "•" if self.opts.title: - print(f"{self.c.Y}{self.opts.title}{self.c.z}", file=sys.stderr) + title = self.c.format(self.opts.title) + print(f"{self.c.Y}{title}{self.c.z}", file=sys.stderr) while True: try: