diff --git a/python_files/pythonrc.py b/python_files/pythonrc.py index 374888ddada5..2edd88874674 100644 --- a/python_files/pythonrc.py +++ b/python_files/pythonrc.py @@ -54,13 +54,13 @@ def __str__(self): result = "" # For non-windows allow recent_command history. if sys.platform != "win32": - result = "{command_finished}{prompt_started}{prompt}{command_start}{command_executed}{command_line}".format( + result = "{command_line}{command_finished}{prompt_started}{prompt}{command_start}{command_executed}".format( + command_line="\x1b]633;E;" + str(get_last_command()) + "\x07", command_finished="\x1b]633;D;" + str(exit_code) + "\x07", prompt_started="\x1b]633;A\x07", prompt=original_ps1, command_start="\x1b]633;B\x07", command_executed="\x1b]633;C\x07", - command_line="\x1b]633;E;" + str(get_last_command()) + "\x07", ) else: result = "{command_finished}{prompt_started}{prompt}{command_start}{command_executed}".format( diff --git a/python_files/tests/test_shell_integration.py b/python_files/tests/test_shell_integration.py index 896df416eced..c5911aad2d1d 100644 --- a/python_files/tests/test_shell_integration.py +++ b/python_files/tests/test_shell_integration.py @@ -13,7 +13,7 @@ def test_decoration_success(): if sys.platform != "win32": assert ( result - == "\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07\x1b]633;E;None\x07" + == "\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07" ) else: pass @@ -28,7 +28,7 @@ def test_decoration_failure(): if sys.platform != "win32": assert ( result - == "\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07\x1b]633;E;None\x07" + == "\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07" ) else: pass