Create a simple .txt file with your ascii art. Here we create ascii-example.txt:
....
-++. ....::....
*%%: ...:
*%%:
*%%:
:+#%%#%%%: =##: =*#%##+-. ... ... =##. *#*
=%%*--=#%%: +%%- .#%%=--+%%+ .:. .:. *%%: #%%
#%% *%%: +%%- =%%- :%%+ .:..:: *%%: #%%
+%%=. :#%%: +%%- :%%*: .+%%+ .::: =%%+. -%%%
=#%%%%*#%: +%%- :*%%%%#*%+ .: +%%%%%*%%
.:: . +%%- ::. . .:. .
+%%-
-=-=%%%.
.*#%%#+.
Put ANSI color codes everywhere you want. Note we're using plain characters so \033 is literally the characters "backslash zero three three" and not a special character in this context.
Example:
💡 Don't forget to reset the colors by appending \033[0m.
Note: In this screenshot I'm using Sublime Text 4 with the "Color Highlight" package, with the following user preferences:
```json
{
"user":
{
"0x_hex_values": true,
"gutter_icon": "circle",
"hex_values": true,
"highlight": true,
"highlight_values": true,
"hsl_values": true,
"hsv_values": true,
"hwb_values": true,
"lab_values": true,
"lch_values": true,
"named_values": true,
"rgb_values": true,
"xterm_color_values": true,
},
}
```
cat won't print your ANSI colors unless you actually added special characters to your file, which is not usual or fun to do.
A workaround is to use echo together with cat and sed:
catreads the filesedmakes sure spaces are taken into accountechointerprets ANSI color codes and prints the result.
$ echo -ne $(cat ascii.txt | sed 's/$/\\n/' | sed 's/ /\\a /g')- Navigate to
/etc/update-motd.d/ - Copy your
ascii-example.txtfile into this directory - In the same location, create a new file with the XX-NAME convention for script ordering. In this example,
99-ascii-example. Open it for editing as root - Create script to read and print the file:
❗ Note that we're using absolute paths to
#!/bin/bash PATH="/etc/update-motd.d/ascii-example.txt" if [ -f "$PATH" ]; then echo -ne $(/bin/cat "$PATH" | /bin/sed 's/$/\\n/' | /bin/sed 's/ /\\a /g') fi
catandsedor else it wouldnt't work (can you tell me why? I didn't look into it) - Save changes and give execution permissions to your file
$ sudo chmod +x 99-ascii-example
- Try your script
$ ./99-ascii-example
- If all is well, you should see your colored ascii art each time you login.

