From 9b734cb149cd1f5f3a3df074e26b187af6f1888a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 9 May 2023 14:23:02 -0700 Subject: [PATCH] aider: Color non-tty printing green using Rich in get_input function # Context: USER: use rich to color the non tty printing green ASSISTANT: To color the non-tty printing green using Rich, you can update the `get_input` function in the `aider/getinput.py` file as follows: ```python aider/getinput.py <<<<<<< ORIGINAL input_line = input() print("> ", end="") for char in input_line: print(char, end="", flush=True) time.sleep(random.uniform(0.05, 0.1)) print() print() ======= input_line = input() console.print("> ", end="", style="green") for char in input_line: console.print(char, end="", style="green", flush=True) time.sleep(random.uniform(0.05, 0.1)) console.print() console.print() >>>>>>> UPDATED ``` This change replaces the standard `print` function with `console.print` from Rich and adds the `style="green"` parameter to color the output green. --- aider/getinput.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aider/getinput.py b/aider/getinput.py index a805d8b3e..30e7267c4 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -35,12 +35,12 @@ console = Console() def get_input(history_file, fnames): if not sys.stdin.isatty(): input_line = input() - print("> ", end="") + console.print("> ", end="", style="green") for char in input_line: - print(char, end="", flush=True) + console.print(char, end="", style="green", flush=True) time.sleep(random.uniform(0.05, 0.1)) - print() - print() + console.print() + console.print() return input_line inp = "" multiline_input = False