summaryrefslogtreecommitdiffstats
path: root/examples/prompts/rprompt.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 04:45:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 04:45:14 +0000
commit5b43aaac61ac94abe722bc98ae58468618f2f512 (patch)
tree3d58c89faa23d194f83abb24ae1fd05067538fff /examples/prompts/rprompt.py
parentAdding upstream version 3.0.43. (diff)
downloadprompt-toolkit-5b43aaac61ac94abe722bc98ae58468618f2f512.tar.xz
prompt-toolkit-5b43aaac61ac94abe722bc98ae58468618f2f512.zip
Adding upstream version 3.0.46.upstream/3.0.46
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/prompts/rprompt.py')
-rwxr-xr-xexamples/prompts/rprompt.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/prompts/rprompt.py b/examples/prompts/rprompt.py
index f7656b7..fd4fe1b 100755
--- a/examples/prompts/rprompt.py
+++ b/examples/prompts/rprompt.py
@@ -6,6 +6,7 @@ is long enough to cover the right side of the terminal.
This is similar to RPROMPT is Zsh.
"""
+
from prompt_toolkit import prompt
from prompt_toolkit.formatted_text import ANSI, HTML
from prompt_toolkit.styles import Style
@@ -30,23 +31,23 @@ def get_rprompt_text():
def main():
# Option 1: pass a string to 'rprompt':
answer = prompt("> ", rprompt=" <rprompt> ", style=example_style)
- print("You said: %s" % answer)
+ print(f"You said: {answer}")
# Option 2: pass HTML:
answer = prompt("> ", rprompt=HTML(" <u>&lt;rprompt&gt;</u> "), style=example_style)
- print("You said: %s" % answer)
+ print(f"You said: {answer}")
# Option 3: pass ANSI:
answer = prompt(
"> ", rprompt=ANSI(" \x1b[4m<rprompt>\x1b[0m "), style=example_style
)
- print("You said: %s" % answer)
+ print(f"You said: {answer}")
# Option 4: Pass a callable. (This callable can either return plain text,
# an HTML object, an ANSI object or a list of (style, text)
# tuples.
answer = prompt("> ", rprompt=get_rprompt_text, style=example_style)
- print("You said: %s" % answer)
+ print(f"You said: {answer}")
if __name__ == "__main__":