How to display random jokes from www.icndb.com in your terminal?
Solution 1:
You can use the icndb RESTful API: http://www.icndb.com/api/.
-
Install the
cowsay
,recode
andjshon
packages:sudo apt-get install cowsay recode jshon
-
Then just add the following lines to your
.bashrc
:if [ "$PS1" ]; then wget "http://api.icndb.com/jokes/random" -qO- | jshon -e value -e joke -u | recode html | cowsay -f tux fi
Note: checking if
$PS1
is set ensures that the jokes won't be displayed on non-interactive sessions. -
Now when I open a
gnome-terminal
I get: