Skip to content

Commit 4c69853

Browse files
committed
Implement colored prompt
1 parent 1417b9b commit 4c69853

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Lib/_pyrepl/reader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import re
2323
import unicodedata
24+
import traceback
2425

2526
from . import commands, input
2627

@@ -420,6 +421,9 @@ def get_prompt(self, lineno, cursor_on_line):
420421
res = self.ps3
421422
else:
422423
res = self.ps1
424+
425+
if traceback._can_colorize():
426+
res = traceback._ANSIColors.BOLD_MAGENTA + res + traceback._ANSIColors.RESET
423427
# Lazily call str() on self.psN, and cache the results using as key
424428
# the object on which str() was called. This ensures that even if the
425429
# same object is used e.g. for ps1 and ps2, str() is called only once.

0 commit comments

Comments
 (0)