The macOS Terminal has a nice "mark" feature that allows you to jump between prompts using Cmd+Up/Down. I'm trying to insert my own "marks" from inside of a Python script so that I can jump to specific parts of the output (example).
Thanks to Armin Briegel, I have:
osascript -e 'tell app "System Events" to keystroke "u" using command down'
This works, but has a few problems. It doesn't add a "mark" if the Terminal is not in focus. Also, it triggers the Terminal bell alert if the Terminal is not in focus. Any way to improve this?