title: Add mark to Terminal in background using AppleScript
body: <p>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 (<a href="https://user-images.githubusercontent.com/12021217/57988005-7fb33700-7a4e-11e9-8516-49ce9575f657.gif" rel="nofollow noreferrer">example</a>).</p>
  
  <p>Thanks to <a href="https://scriptingosx.com/2017/03/terminal-the-marks-the-spot/" rel="nofollow noreferrer">Armin Briegel</a>, I have:</p>
  
  <pre class="lang-sh prettyprint-override"><code>osascript -e 'tell app "System Events" to keystroke "u" using command down'
  </code></pre>
  
  <p>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?</p>