Having set a lecture with Default lecture=always
and Default lecture_file=/etc/sudoers.lecture
, I would like to add colour to it. ANSI escape characters show without escaping, and creating a wrapper function displays it every time I use sudo, even if the password is in the cache.
Asked
Active
Viewed 414 times
2

Jeff Schaller
- 67,283
- 35
- 116
- 255

gadzooks02
- 141
- 4
1 Answers
2
Using:
echo $(tput setaf <colour>)<text>$(tput sgr0) >> /etc/sudoers.lecture
adds coloured text to /etc/sudoers.lecture

gadzooks02
- 141
- 4
lecture
? – k.stm Aug 23 '19 at 17:05sudoers(5)
manual. It is the short text that is outputted upon first usingsudo
, which (by default) reminds the user to use the command responsibly. – Kusalananda Aug 23 '19 at 17:22tput
output, I created a file that sudo dutifully outputted in color. How did you produce the /etc/sudoers.lecture file? – Jeff Schaller Aug 23 '19 at 18:38tput
works. – gadzooks02 Aug 25 '19 at 18:28tput
works, but I cannot get it to display colour when put in sudoers,lecture. – gadzooks02 Aug 27 '19 at 18:00$TERM
is the critical piece, I think. – Jeff Schaller Aug 27 '19 at 18:13tput
to generate the colored text? – Jeff Schaller Aug 27 '19 at 18:15$(tput setaf <number>)
to sudoers.lecture, then yes – gadzooks02 Aug 27 '19 at 18:21echo $(tput setaf <number>)<text> >> /etc/sudoers.lecture
– gadzooks02 Aug 27 '19 at 19:32