Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wish to display a cowsay message in every terminal window. The command I use is

 fortune | cowsay

Any ideas how to make it appear whenever I start a new terminal session?

share|improve this question

3 Answers 3

up vote 18 down vote accepted
  • Open the file ~/.bashrc (or /etc/bash.bashrc if it should work globally for all users).

  • Add the following at the bottom of the file:

    if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
        fortune | cowsay
    fi
    
share|improve this answer
    
does the -x flag mean "if exists" ? –  theTuxRacer Dec 6 '10 at 16:58
1  
Yes, "-x" tests if that file exists and is executable. For more information on the the test program see its man page: man test ([ ... ] is short for test ...). –  htorque Dec 6 '10 at 17:03

BONUS: If you're using bash you can make a ~/.bash_logout file and it will execute that when you log out. Make sure to have it sleep for a second or so, or you'll never see it.

cowsay "See you later"; sleep 1

share|improve this answer
    
wow, thats neat! Ill do it immediately! –  theTuxRacer Jan 24 '11 at 7:54

I would consider setting a limit to the size of the fortune command requested.

fortune -s | cowsay

This will produce at most 160 characters. This is a good size for a greeting, anything more than that and long fortunes will flood your terminal.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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