I need a text banner on a screen which is projected all the time. The screen is connected to a PC with tmux on it.

Example of text "banners":

figlet $(fortune)


toilet "$(cowsay $(fortune))"

You get the idea.

Initially we thought this banner would need "regeneration capabilities" in case something went wrong, so we did something like this:

watch --interval 1 --no-title echo Paranoid about crashes, but I should not be

but the thing never crashed in a year! (uptime > 1yr)

So we are simplifying and deploying somewhere else too. I just want a UNIX command that does the following:

  • clear the screen (like clear)
  • shows a formatted string (like printf)
  • is modal (like an ncurses app)

I started to write something like this, pinched off of a web tutorial:

#include <ncurses.h>

int main(int argc, char** argv) {
  char* greeting = "Hello, world!";
  return 0;

but this is not "modal" (with modal being: disregard all input until CTRL+C) and I may be "rewriting an existing tool".

Which UNIX tool would you use in my case?


The command to watch for Ctrl+C (the INT signal) is trap.


MSG="Hello, world!"
trap "clear; echo -e $MSG" SIGINT SIGTERM

while :
    sleep 60

Update - Other signals that can be caught with trap

SIGINT - Ctrl-c
SIGQUIT - Ctrl-\ (this will quit the program, but commands in trap will still be executed)

SIGSTOP (Ctrl-z) doesn't seem to be caught by trap.

trap can also catch signals issued by kill, but I'm not sure how many of them can be caught.

trap also supports some other special names:-
Further documentation on these can be found in the bash reference manual.

  • Simple. Elegant. Trapping SIGINT is golden. Thank you! You could add a link to a list of signals to make your answer even more useful to others stumbling on it... – Robottinosino Oct 16 '12 at 6:01
  • 1
    I had a hunt through some man pages on my Linux box (signal, 7 signal, kill, posix, etc.), but couldn't find any info on keyboard-shortcut to signal mappings. I know a couple though; I'll add them to the answer.. – Alex Leach Oct 17 '12 at 17:40
  • Good man... and thorough! (cit.) – Robottinosino Oct 17 '12 at 22:20

If I understand, you want an infinite loop:

while :; do
  sleep 1
  # the command: echo, toilet, etc.

Maybe, the problem with watch is that the shell expansion of $(command ..) is done once before watch is called so output doesn't change ; change double quotes to single quotes

watch --interval 1 'cowsay $(fortune)'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.