A minor, yet annoying situation is when a command's output doesn't end with a newline character, resulting in the final line merging into the shell prompt. While one easy solution it so add \n at the beginning of your shell prompt, I'm not really a fan of the extra blank line this adds to the common case. So a different solution, affecting only the missing newline scenario, was desired.
While I did find a handful of examples online for ways to handle this, they tended to either be overly complex or completely lacking in explanation. So after playing with it for far more time than this meager problem deserves, I thought it might be useful to share the version I settled on along with an explanation of how/why it works.
- Assign a short string to indicate that the ending newline is missing. For example: