I made it work by wrapping bpy.console.execute(), then setting it afterward:
import bpy
class CONSOLE_OT_execute_wrapper(bpy.types.Operator):
"""Wraps command execution to maintain the current prompt."""
bl_idname="console.execute_wrapper"
bl_label="Execute Wrapper"
interactive=bpy.props.BoolProperty(name="Interactive",description="Whatever the \"interactive\" property does for bpy.ops.console.execute.",default=False)
prompt=bpy.props.StringProperty(name="Prompt",description="String that shows to the left of the current command.")
@classmethod
def poll(cls,C):
return C.area.type=="CONSOLE"
def execute(self,C):
print("CONSOLE_OT_execute_wrapper.execute(%s,%s)"%(self,C))
bpy.ops.console.execute(interactive=self.interactive)
C.space_data.prompt=self.prompt
return {'FINISHED'}
def register():
bpy.utils.register_class(CONSOLE_OT_execute_wrapper)
for kmi in [kmi for kc in bpy.context.window_manager.keyconfigs for km in kc.keymaps for kmi in km.keymap_items if kmi.idname=="console.execute"]:kmi.idname+="_wrapper"#Wrap
def unregister():
bpy.utils.unregister_class(CONSOLE_OT_execute_wrapper)
for kmi in [kmi for kc in bpy.context.window_manager.keyconfigs for km in kc.keymaps for kmi in km.keymap_items if kmi.idname=="console.execute_wrapper"]:kmi.idname=kmi.idname[:kmi.idname.rindex("_")]#Unwrap
if __name__=="__main__":register()
After running the above in the text editor, for now you can then set the prompt in User Preferences->Input, where you expand "Console", find each "Execute Wrapper" and set their "prompt" property. I'll put the option somewhere appropriate in the addon.