I already know that you can get some nice quotes/jokes using the fortune program.

But I've found in this urwird script a new source of fun that I'd like to have when I open a new terminal.

This time the jokes come from http://www.icndb.com.

1 Answer 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

    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

  • 3
    If you're installing cowsay, you might as well install jshon too. It makes parsing the JSON a lot more concise (and probably faster): wget "http://api.icndb.com/jokes/random" -qO- | jshon -e value -e joke -u
    – Oli
    Commented Sep 23, 2014 at 12:52
  • 1
    I'm not sure you'll need that (recode) with JSON. And jshon's -u should return a decoded string anyway.
    – Oli
    Commented Sep 23, 2014 at 13:10
  • 1
    Fair enough. That's icndb.com's fault more than JSON.
    – Oli
    Commented Sep 23, 2014 at 13:14
  • 1
    I'm pretty sure the default ~/.bashrc already checks if it's an interactive shell ([[ $- != *i* ]] && return).
    – user7509
    Commented Sep 23, 2014 at 13:32
  • 2
    No need for a backslash for line continuation after a pipe. The pipe causes the line to be continued by itself. Commented Sep 23, 2014 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .