This is a small revision to the move_cursor_to_start_of_ps1 function described in ‘When did I run that command?’. The original relies on a specific number of lines in PS1; this works with an arbitrary number of lines.
The original code works correctly for the PS1 provided in the article, but my PS1 has an additional line, and I wanted to avoid using a magic number in case I change my PS1 in the future.