1

For some reason the color escape characters in my /etc/issue file are not working. They're being displayed as text:

Here is the content of the file:

^[[1;31mUbuntu^[[0m

And it outputs the exact same thing at the login prompt:

^[[1;31mUbuntu^[[0m

The escapes are not properly recognized, so how can I solve that?

Atomiklan
  • 405
  • 1
  • 5
  • 20

1 Answers1

5

The escape codes needs to be interpreted correctly and not literally, before writing the string to file:

# echo -e '\e[1;31mUbuntu\e[0m' > /etc/issue
  • How weird, sort of get it now... – Wilf Dec 09 '13 at 21:37
  • @wilf @ErikCalvalho FYI, using the # and $ before a command is a well established norm to express "run the following command as root" or "run the following command as normal user", respectively, so please don't make any more edit suggestions to that particular issue. The command here needs to have root privileges, so it's important to point out. –  Dec 10 '13 at 08:25
  • Yes, but it won't work with the # in the code block - sorry, but can't you just put RUN THIS AS ROOT or sudo.... ? – Wilf Dec 10 '13 at 11:19
  • 1
    @wilf Everyone knows that. The intent is clear - no need for "run the following as root" or "you need to have administrative rights". You'll see this used everywhere in command-line examples on the web and at SE sites. The # $ prefixes are useful to distinguish between commands and output. –  Dec 10 '13 at 12:58
  • 1
    I thought it was pretty self explanatory. Didn't even really think think about it. Just read the line in my head as root. It's kinda like that first instance when you start reading a new language as itself, not a translation. – Atomiklan Dec 10 '13 at 18:15