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.
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.
You can use the icndb RESTful API: http://www.icndb.com/api/.
Install the cowsay
, recode
and jshon
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:
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
jshon
's -u should return a decoded string anyway.
~/.bashrc
already checks if it's an interactive shell ([[ $- != *i* ]] && return
).
Sep 23, 2014 at 13:32