Roman Cheplyaka

Getting Random Things Done: fetching a random card from Trello

January 22, 2017

I am a big fan of randomness. Often when I struggle with a decision, be it what to have for lunch or how to name a baby, I pick a magic ball random number generator and do whatever it tells me.

Randomness is especially helpful in deciding what to do next. This is a decision we make many times a day, and it can consume a lot of mental energy.

In Getting things done, David Allen suggests a four-criteria model for choosing actions. Four criteria! That sounds like a lot of work in itself. Why don’t we delegate this decision to chance?

Since I use Trello as my GTD system, I developed a simple UNIX shell script to fetch random Trello cards from a particular list (such as “Next actions” or “To read”). If you would like to try it out, follow the instructions below.


First, go to and copy the API key it generates. That page also has a link to generate a token “if you are looking to build an application for yourself” — and that’s exactly what you are doing. So go ahead and generate a token.

Save the API key and the token you’ve got to shell variables:


Next, you need to find out the id of the list you are interested in. Even the official docs admit that

One of the trickier parts of using the Trello API for simple use cases is finding a List ID that belongs to a user.

Follow their instructions to get the list id. Then create a shell variable to hold it:


Once you have the right data in the right variables, simply run the following pipeline in your shell prompt:

curl -Ns "$TRELLO_LIST/cards/open?key=$TRELLO_KEY&token=$TRELLO_TOKEN" |
  jq -r '.[] | "\(.name): \(.desc)\n" | @base64' |
  shuf -n 1 |
  base64 --decode

(The base64 encoding/decoding is needed to handle correctly descriptions that span multiple lines.)

You can put the above commands into a file and make it an executable script. For instance, I have scripts random-trello-action and random-trello-paper.