Open bonecountysheriff opened 1 year ago
I need to temporarily use color codes like "\033[0m". But prompt() doesn't seem to allow it.
prompt()
I've tried using print() to achieve this, followed by prompt(), but as soon as I hit enter after the input, the prompt disappears. Any way around this?
print()
This is the code snippet I'm currently using.
print(f"\033[32mprompt> \033[0m", end='') content = session.prompt(multiline=True, prompt_continuation=prompt_continuation)
If you have strings with raw ansi codes, Wrap them with prompt_tookit.ANSI(), e.g.:
prompt_tookit.ANSI()
from prompt_toolkit import ANSI, prompt prompt(ANSI("\033[32mprompt>\033[0m "))
Docref: https://python-prompt-toolkit.readthedocs.io/en/master/pages/printing_text.html?highlight=ansi#formatted-text
I need to temporarily use color codes like "\033[0m". But
prompt()
doesn't seem to allow it.I've tried using
print()
to achieve this, followed byprompt()
, but as soon as I hit enter after the input, the prompt disappears. Any way around this?This is the code snippet I'm currently using.