Thumbs up for fortunes in your terminal!
So, background info first. I installed the Linux Mint 12 RC a few days ago, but to my chagrin, fortunes had disappeared from the terminal! Even changing the Desktop Settings didn’t help, so I set out to remedy this tragedy. After searching around I found some pretty handy tips at the Ubuntu Forums, and I will now present my own cohesive tutorial in all entirety.
First, open up your terminal. What do you see? I’m guessing not much other than $USER@$HOSTNAME ~ $. It is our mission to change this.
So, here’s what we’re going to do. Run the following command in the terminal:
sudo apt-get install cowsay fortune-mod
Now open your bash.bashrc file by running
sudo gedit /etc/bash.bashrc
At the very end of the file, paste this:
#!/bin/bash RANGE=7 number=$RANDOM let "number %= $RANGE" case $number in 0) cow="apt" ;; 1) cow="tux" ;; 2) cow="mech-and-cow" ;; 3) cow="www" ;; 4) cow="stegosaurus" ;; 5) cow="vader-koala" ;; 6) cow="meow" ;; esac RANGE=2 number=$RANDOM let "number %= $RANGE" case $number in 0) command="cowsay" ;; 1) command="cowthink" ;; esac fortune -a | $command -f $cow
This is the easiest way to get fortunes in your terminal, but for more options, read on.
Still here? Cool. Here’s where the customization really gets fun. If you want to swap, add, or remove the cows, here’s how:
To get a full list of the names of all the cows, run
If you want to actually see what the cows look like, navigate to /usr/share/cowsay/cows
Basically, all you have to do is replace the name of the cow (minus the .cow suffix) into the code above. For example, if I wanted only three random cows to appear, I could change this part of the code
RANGE=7 number=$RANDOM let "number %= $RANGE" case $number in 0) cow="apt" ;; 1) cow="tux" ;; 2) cow="mech-and-cow" ;; 3) cow="www" ;; 4) cow="stegosaurus" ;; 5) cow="vader-koala" ;; 6) cow="meow" ;;
to something like this:
RANGE=3 number=$RANDOM let "number %= $RANGE" case $number in 0) cow="dragon-and-cow" ;; 1) cow="tux" ;; 2) cow="www" ;;
Just make sure that you change the RANGE value accordingly, and don’t forget that the numbering starts at 0!
Have fun with your cowsay fortunes!
For bonus points (or if you’re feeling extra geeky), you can also have a bit more fun and set terminal to display a custom message as well as a fortune. For example, I have my terminal set to display this message in addition to my fortune:
-> Authorized users - Welcome to pfjappaco's Axcessor running Linux Mint 12 Lisa: Release Candidate. -> Unauthorized users - Please be advised: Use of this computer without prior authorization will be met with annihilation. -> Sadranorion - SUDO WITH HONOR.
Here’s how to do it yourself:
Write up your message in your favorite text editor and save it as .terminal in your home folder. (You could technically save it wherever you like, but the next few commands are tailored to it being saved as .terminal in your home folder)
Now open /etc/bash.bashrc by running
sudo gedit /etc/bash.bashrc
If you want to have your custom message displayed above your fortune, paste the following code above the fortune code. If you want your message displayed below your fortune, paste the following code underneath the fortune code.
Cool. Now save the file and open up your terminal. If you got everything right, it should look something like this:
For even more awesomeness, you can even add other commands to bash.bashrc such as
For any questions, comments, or concerns, just give me a heads up in the comments section!
- “How to jazz up your remote login terminal” Ubuntu Forums. 2011. Web. 16 November 2011. <http://ubuntuforums.org/showthread.php?t=32076>