A couple of days ago, I found https://buddha-api.com/, which has an API for getting quotes from important figures in Buddhism.

My first thought was to create a webpage that displays the quote, but they already did that, and I don’t like doing something someone else has already done.

So my next thought was to display it in my terminal. Running the following command:

curl -s -X GET https://buddha-api.com/api/today

We get the following JSON output:

{"id":"dogen-2","text":"Forgetting oneself is opening oneself.","byId":"dogen","byName":"Dogen","byImage":"https://buddha-api.com/img/buddhist/dogen.png"}

Not readable by normal standards, but it’s a start. If we use jq, we can convert it from JSON into a more human-readable format:

curl -s -X GET https://buddha-api.com/api/today | jq -r '[.text, .byName] | join("\n -- ")'

This takes the text and byName keys from the JSON object, puts them in an array, and then combines the two elements in the array into the following string:

Forgetting oneself is opening oneself.
-- Dogen

That’s a nice little quote! But I had even more time to waste, so let me introduce you to one of my favorite programs, cowsay:

echo 'Hello there, reader!' | cowsay
 ______________________ 
< Hello there, reader! >
 ---------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Don’t like cows? How about a koala?

echo 'Hello again' | cowsay -f koala
 ______________ 
< Hello again! >
 -------------- 
  \
   \
       ___  
     {~._.~}
      ( Y )
     ()~*~()   
     (_)-(_)   

So we can pass it in that quote we got from the API into cowsay, and get:

curl -s -X GET https://buddha-api.com/api/today | jq -r '[.text, .byName] | join("\n -- ")' | cowsay
 ________________________________________ 
/ Forgetting oneself is opening oneself. \
|                                        |
\ -- Dogen                               /
 ---------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

But I think it’s a little silly to see a Buddhist quote coming from a cow! Or a koala! What about well, an actual representation of the Buddha? Is that even possible?

echo 'Yes, yes it is!' | cowsay -f little-buddha
 _________________ 
< Yes, yes it is! >
 ----------------- 
           \
           \
              _=_
            q(-_-)p
            '_) (_`
            /__/  \
          _(<_   / )_
         (__\_\_|_/__)

I found the image above, and an even more detailed one, from https://www.asciiart.eu/religion/buddhism.

We can take those text buddhas, and with a little modification, put them in a directory (in my case /usr/share/cows) as files such as little-buddha.cow for use by cowsay. Credit goes to whoever made the above image.

So, the final result is:

curl -s -X GET https://buddha-api.com/api/today | jq -r '[.text, .byName] | join("\n -- ")' | cowsay -f little-buddha
 ________________________________________ 
/ Forgetting oneself is opening oneself. \
|                                        |
\ -- Dogen                               /
 ---------------------------------------- 
           \
           \
              _=_
            q(-_-)p
            '_) (_`
            /__/  \
          _(<_   / )_
         (__\_\_|_/__)

Pretty cool, right?

For reference, here’s a Github gist containing the little-buddha.cow I was showing earlier.

I hope you had as much fun reading this as I had making it! Namaste!