Making your Bash Shell More Interesting Using Fortune
Every time I open a new shell prompt, a message similar to the one below greets me:
The witty message is provided by fortune, and you too can have something similar.
Using your package manager, install fortune
, e.g. if you use Homebrew on OS X, run:
Test installation by running fortune on your command line:
I suggest you skim through man fortune
to get your head wrapped around how fortune works. I’ll just highlight a few options:
-a
- Will select a random epigram that could be or not be offensive-o
- Will select a random epigram that’s offensive
Running fortune without a flag just selects a random, non-offensive epigram.
Quoting the man page, use -a
and -o
if and only if you believe, deep in your heart, that you are willing to be offended.
Next, adding it to your bash. Edit your bash prompt config file. For some, it’s usually ~/.bash_profile
, others, ~/.bashrc
Add this to the end of the file:
This means that the command will be run every time the config file is run (which is usually the case when you open a new bash shell)
Save and exit the file, then run soure ~/.bash_profile
Now any time you open a shell, a random epigram will be displayed.
Have fun!