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

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

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

Postby sagirfahmid3 on Tue Jul 17, 2012 3:08 pm

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.
User avatar
sagirfahmid3
Level 6
Level 6
 
Posts: 1054
Joined: Sun Sep 04, 2011 12:39 pm

Linux Mint is funded by ads and donations.
 

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

Postby Tim_Olaguna on Sun Aug 12, 2012 2:58 pm

Thanks so much for helping to brighten my days and life. :D
Cheerily Yours,
Tim O'Laguna
Tim_Olaguna
Level 1
Level 1
 
Posts: 13
Joined: Mon Nov 03, 2008 2:58 pm
Location: Sacramento, California, USA

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

Postby sagirfahmid3 on Sun Aug 12, 2012 5:39 pm

No problem :mrgreen: Except, some of the creatures can be a bit mean sometimes... :shock:
Image
User avatar
sagirfahmid3
Level 6
Level 6
 
Posts: 1054
Joined: Sun Sep 04, 2011 12:39 pm

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

Postby nuambenzina on Thu Nov 28, 2013 4:04 pm

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
nuambenzina
Level 1
Level 1
 
Posts: 8
Joined: Thu Nov 28, 2013 2:43 pm

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

Postby Corvalis on Sat Jan 25, 2014 2:19 pm

Wonderful How-To! :D
Horace: Sedit qui timuit ne non succederet - He who feared he would not succeed sat still. (For fear of failure, he did nothing.)
Corvalis
Level 1
Level 1
 
Posts: 16
Joined: Wed Dec 19, 2012 7:30 pm


Return to Tutorials / Howtos

Who is online

Users browsing this forum: Google Adsense [Bot] and 11 guests