Prints a "🚫" character and adds a newline if the cursor is not in column 1. You can use it in your shell prompt to tidy up after commands that output some text without a trailing newline.
Go to file
Laurence Withers bd0d1aaebe Improvements: cope with extra input chars and replay
This still suffers a bit if the user does manage to type anything during the invocation, because the
simulated input characters get echoed to the terminal and mess up the nicely-aligned newline we just
made.
2023-04-28 12:22:51 +01:00
.gitignore Initial version 2023-04-07 16:32:39 +01:00
LICENSE Initial version 2023-04-07 16:32:39 +01:00
README.md Initial version 2023-04-07 16:32:39 +01:00
example.gif Initial version 2023-04-07 16:32:39 +01:00
go.mod Initial version 2023-04-07 16:32:39 +01:00
go.sum Initial version 2023-04-07 16:32:39 +01:00
main.go Improvements: cope with extra input chars and replay 2023-04-28 12:22:51 +01:00

README.md

missingnewline

Prints a "🚫" character and adds a newline if the cursor is not in column 1. You can use it in your shell prompt to tidy up after commands that output some text without a trailing newline.

Example terminal session showing the problem of an unterminated command mixing with the shell prompt, and then the program correctly detecting the presence or absence of a non-newline-terminated output and using the "🚫" character appropriately.

You can install this into your ~/.bashrc, for example:

declare -a PROMPT_COMMAND
if [ -x "${HOME}/go/bin/missingnewline" ]
then
  PROMPT_COMMAND+=("${HOME}/go/bin/missingnewline")
fi