5

How about a slightly different approach? Rather than remove the escape characters and sequences, you can allow users to use them to edit the input line with read -e. If you want, you can take this even further by recording chat message history, like this: ... read -e -p "Message: " msg history -s "$msg" ... With this, if someone makes a typo in a message, ...


2

Strip any non-printing character from the message string: #!/bin/bash while read -p 'Message: ' message; do printf '[%s] User: %s\n' "$( date +%T )" "${message//[^[:print:]]/}" done >>file.txt The parameter substitution ${message//[^[:print:]]/} would expand to the value of the variable message with any non-printable character removed. In ...


1

You can pass through some text to the terminal screen itself runs in by putting it inside an ESC P, ESC \ pair (\033P%s\033\\ in printf format). So you should bracket inside \eP..\e\\ pairs all the parts of the sequence, except for the text which will appear on the screen ("This is a link"): printf '\eP\e]8;;https://example.com\a\e\\This is a link\eP\e]8;;...


1

I would like to point out if you wants to change Screen settings globally (all users) then you can edit /etc/screenrc file. (Ubuntu). File path might be different on other distros. In your case you can add the following lines to the file: # define a bigger scrollback, default is 100 lines defscrollback 1024


Only top voted, non community-wiki answers of a minimum length are eligible