Cowsay Fortune
Objective
Being greeted by a cow predicting your fortune every time you open a bash terminal.
Example
___________________________________
< Beware of low-flying butterflies. >
-----------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Storytime
Fortune-teller cow wasn't known for her milk production,
but for her uncanny ability to see the future.
Farmers flocked to her pasture, eagerly awaiting a swish of her tail
(left meant sunshine, right meant rain).
Installation
-
Install fortune and cowsay
First, you need to ensure that both
fortuneandcowsayare installed on your system. You can do this using your package manager. For example, on Ubuntu or Debian-based systems, you can useapt:For other Linux distributions, you might use
yum,dnf, or another package manager appropriate to your system. -
Modify your .bashrc file
Once you have
fortuneandcowsayinstalled, you can modify your.bashrcfile to display a random fortune each time you open a new terminal window or tab.Open your
.bashrcfile in a text editor. You can do this with the following command:Scroll to the bottom of the file, and add the following lines:
# Display a random fortune with cowsay when opening a new terminal if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then fortune | cowsay fiSave the file by pressing
Ctrl + O, then pressEnterto confirm, and exit Nano by pressingCtrl + X. -
Test it out
Open a new terminal window or tab, and you should see a random fortune displayed in a speech bubble created by a cow! Each time you open a new terminal, you'll see a different fortune.
That's it! You've successfully installed fortune and cowsay on your Bash shell and configured it to display a random fortune each time you open a new terminal session.