Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMDE

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
sagirfahmid3

Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMDE

Post by sagirfahmid3 »

Hi folks, just a really quick how to here about having the option to enable automatic fortunes every time you open a terminal.
I saw that Mint 13 and LMDE (as well as the Debians don't show fortunes automatically by default). Who wants to stare at a boring old terminal screen?
Have some fun with fortunes! :D Have some more fun with cowsay and the numerous creatures available! :P Have one or have em all! :lol:
It's really easy too; all you need to do is edit your .bashrc in your home folder (it's hidden, press Ctrl+H to see hidden files and folders) and add one line of code to it.
Image
If you don't know what fortune is, it's basically a program that shows random quotes, fortunes, and sayings--many from famous authors, many from well respected Linux users (like Husse for example), and some from anonymous users. If you don't already have fortune installed, the command to install it is:

Code: Select all

sudo apt-get install fortune-mod
Cowsay is another simple and fun program. What it does is it takes the input of whatever you (or another program inputs), and outputs it as a creature who responds with a "thought bubble." Some of my favorites are dragon, tux, elephant, tortoise, duck, and rabbit. There are over 40 different creatures available in the default package (you have the option of adding more). If you don't have cowsay installed by default, the command to install it is:

Code: Select all

sudo apt-get install cowsay
Now that you have the required programs installed (or already HAD them installed), here is the tutorial:

Option 1: Automatic fortunes + cowsay

This option will automatically display a fortune ALONG with a random cowsay creature whenever you open a terminal.
First: Open a terminal
Second: Paste this in the terminal. Hit enter and you're done. Close the terminal, reopen it and voila! (Read the explanation if you want to know how the command works).

Code: Select all

echo 'cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) $(fortune)' | tee -a /home/$USER/.bashrc

Now, here is the explanation. The "cowsay -f" option allows a person to choose a creature to say the thought (in this case I made it random);
the "ls /usr/share/cowsay/cows/" lists all the .cow files (which contain the creatures) and the list is handed over to "shuf" which obviously shuffles or randomizes them;
the "fortune" bit is the actual fortune that is outputted via the random animal; the "tee -a" takes the output of what "echo" echoed and adds it at the end of a file (over here, that is .bashrc). You COULD use gedit (pluma) or leafpad to edit the .bashrc file, but I'm to lazy to do that :mrgreen:

Option 2: Automatic fortunes ONLY

Paste the following line in a terminal and press enter. Close the terminal, reopen it again, and ta-daaa! (Not much to explain here. Read the explanation above).

Code: Select all

echo 'fortune' |tee -a /home/$USER/.bashrc
Option 3: On-demand fortunes + cowsay

This is a good idea if you're not bored all the time, but when you are bored, you can call the cows and other creatures on demand to entertain you.
Paste the following line in a terminal and press enter. Close the terminal, reopen it. (Note: for the alias, the command should NOT be "fortune" as it is already used).

Code: Select all

echo alias fortunes=\''cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) $(fortune)'\' | tee -a /home/$USER/.bashrc
To call on the cowsay-fortune combo, just type in "fortunes" in the terminal. Enjoy!
Explanation. The "alias" acts like a placeholder so when you issue your custom command, it will execute whatever you set that alias to.
Now whenever you want to call on the animals and fortunes, type in "fortunes" in the terminal and press enter! That's it!
Wikipedia can explain more: http://en.wikipedia.org/wiki/Alias_%28command%29

Thanks for looking at my tutorial! I hope you've enjoyed it as much as the funny quotes and awesome animals!
That concludes my tutorial. If you have any suggestions, or if any of the commands fail to work, do let me know here...I don't appreciate messages unless its crazy important.
If for some reason you want to remove these commands, you can easily edit the .bashrc file in your home folder using Gedit (Pluma), Geany, Nano, or Leafpad and remove the parts that you don't require. Here's a screenshot of some of the more "interesting" creatures (and things) that I liked:
Image

Tags (ignore this. It's here so the Google bots can find this how-to easily): fortunes-mod, fortunes, cowsay, automatic fortunes, auto fortunes, automatic cowsay, auto cowsay, cowsay and fortune, cowsay with fortune, random cowsay, random fortunes and cowsay.
Tim_Olaguna

Re: Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMD

Post by Tim_Olaguna »

Thanks so much for helping to brighten my days and life. :D
sagirfahmid3

Re: Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMD

Post by sagirfahmid3 »

No problem :mrgreen: Except, some of the creatures can be a bit mean sometimes... :shock:
Image
nuambenzina

Re: Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMD

Post by nuambenzina »

Well, using the instructions from here I've messed something up.

Then so, I asked on linux mint help chat, someone called Ben helped me and I did this:

Copy the .bashrc back / restore .bashrc to default:

Code: Select all

cp /etc/bash.bashrc ~/.bashrc
then I changed the directory to skel:

Code: Select all

cd /etc/skel
and from there:

Code: Select all

  echo 'cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) $(fortune)' >> ~/.bashrc && echo 'fortune' >> ~/.bashrc 
Now, everything is Looking good here, I wroted as maybe will be helpfull for someone else who read / search on google about fortunes, cowsay, and resteting the .bashrc file
Corvalis

Re: Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMD

Post by Corvalis »

Wonderful How-To! :D
RandyRNose

Re: Mini-HowTo: Fortunes + Cowsay (+random creatures) in LMDE

Post by RandyRNose »

Thanks. This was simple and to the point. I was trying to figure out why Cowsay wasn't working after I installed it. Installing it simply doesn't get the desired results. - Seems kind of funny / funky that installing it doesn't just activate it in the Terminal.
Post Reply

Return to “Tutorials”