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/.

  1. Install the cowsay, recode and jshon packages:

    sudo apt-get install cowsay recode jshon
    
  2. 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.

  3. Now when I open a gnome-terminal I get:

    enter image description here