Here are my tries:The last one worked, but it breaks copy-pasting (adding a lot of spaces when copied). Is there a better way?Copyable text:$ PS1='\['$'\x1b[0m\]$ '$ echo -e \x1b[41;37mWarning text\x1b[0m; echo Normal textWarning textNormal text$ echo -ne \x1b[41;37mWarning text$'\n'\x1b[0m; echo Normal textWarning textNormal text$ echo -ne \x1b[41;37mWarning text$'\n'\x1b[47;30m; tr </dev/zero \\0 \ |head -c 80; echo -ne \x1b[A;  echo Normal textWarning textNormal text                                                                     $ $ t=Warning text;echo -ne \x1b[41;37m;echo -n $t;{ tr </dev/zero \\0 \ |head -c $(bc <<<$(stty -a <&3|grep -Po '(?<=columns )[0-9]+')-$(wc -c<<<$t)+1); } 3<&0;echo -e \x1b[0m;echo Normal textWarning text                                                                    Normal text$ 
How to change the background color for exactly one line?
terminal;escape characters
Found the solution myself (in this related question). Use this:echo -e '\x1b[41;37mWarning text\x1b[K\x1b[0m';echo Normal textThe documentation says about \x1b[K:       K   EL        Erase line (default: from cursor to end of line).                     ESC [ 1 K: erase from start of line to cursor.                     ESC [ 2 K: erase whole line.