I'm trying to enable reverse video on bash / xterm such that the text is black but the foreground is white. But it's not working. Here's my command:
echo -n -e \\x1B\\x07maaa\\x1B[m
Any ideas why it's not behaving as expected?
In the example
echo -n -e \\x1B\\x07maaa\\x1B[m
the \\x07m
cannot be correct, since that would be an ASCII BEL. Perhaps you meant something like this:
echo -n -e \\x1B[7maaa\\x1B[m
The \\x1B
is the escape character. All of the other characters are from the printable-ASCII range. This assumes that your echo
interprets escapes in that manner (bash's does).
More portable are
tput rev
for reverse mode and
tput sgr0
to clear reverse mode.
It will be far simpler to use bash
's printf
command (and as Thomas Dickey pointed out, you're using the wrong sequence to enable inverse video). Asking yourself how many backslashes you need to stack up is almost always the wrong question.
# \e[7m starts inverse video
# \e[m (short for \e[0m) resets all video parameters to their default values
printf '\e[7maaa\e[m'