Colouring MOTD

Terminal should be ANSI compliant and support colour escape sequences. Modern terminal should do the job.

The following is a list of escape sequences

The ^[ is produced by pressing Ctrl-V then ESC

I’m using vi as text editor and there’s no problem with ctrl-V ESC, i’m not test it on other text editor.

^[[0m    - Reset the terminal characteristics
^[[1m    - emphasis (bold)

^[[30m    - Foreground black
^[[31m    - Foreground red
^[[32m    - Foreground green
^[[33m    - Foreground yellow
^[[34m    - Foreground blue
^[[35m    - Foreground magenta
^[[36m    - Foreground cyan
^[[37m    - Foreground white

^[[40m    - Background black
^[[41m    - Background red
^[[42m    - Background green
^[[43m    - Background yellow
^[[44m    - Background blue
^[[45m    - Background magenta
^[[46m    - Background cyan
^[[47m    - Background white

example

# vi /etc/motd

^[[32m#########################################^[[0m
^[[32m#           my.server.com               #^[[0m
^[[32m#########################################^[[0m
^[[0m

example

coloured motd

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *