diff --git a/python_files/pythonrc.py b/python_files/pythonrc.py index 005b06bcdd15..63c52bc009da 100644 --- a/python_files/pythonrc.py +++ b/python_files/pythonrc.py @@ -52,7 +52,9 @@ def __str__(self): result = "" # For non-windows allow recent_command history. if sys.platform != "win32": - result = "{command_executed}{command_line}{command_finished}{prompt_started}{prompt}{command_start}".format( + result = "{soh}{command_executed}{command_line}{command_finished}{prompt_started}{stx}{prompt}{soh}{command_start}{stx}".format( + soh="\001", + stx="\002", command_executed="\x1b]633;C\x07", command_line="\x1b]633;E;" + str(get_last_command()) + "\x07", command_finished="\x1b]633;D;" + str(exit_code) + "\x07", diff --git a/python_files/tests/test_shell_integration.py b/python_files/tests/test_shell_integration.py index 574edfc056b4..7503a725b6d1 100644 --- a/python_files/tests/test_shell_integration.py +++ b/python_files/tests/test_shell_integration.py @@ -17,7 +17,7 @@ def test_decoration_success(): if sys.platform != "win32" and (not is_wsl): assert ( result - == "\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07" + == "\x01\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07\x02>>> \x01\x1b]633;B\x07\x02" ) else: pass @@ -32,7 +32,7 @@ def test_decoration_failure(): if sys.platform != "win32" and (not is_wsl): assert ( result - == "\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07" + == "\x01\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07\x02>>> \x01\x1b]633;B\x07\x02" ) else: pass