Skip to content

Instantly share code, notes, and snippets.

@wildcard
Created August 17, 2017 13:40
Show Gist options
  • Save wildcard/9b90e69a086f470f2e90ae5802b84413 to your computer and use it in GitHub Desktop.
Save wildcard/9b90e69a086f470f2e90ae5802b84413 to your computer and use it in GitHub Desktop.
Show Trello list cards in bitbar
#!/bin/bash
JQ=/usr/local/bin/jq
export $(egrep -v '^#' ~/.bitbar/.env | xargs)
TRELLO_API="https://api.trello.com/1"
TRELLO_AUTH_QS="key=$TRELLO_DEVELOPER_PUBLIC_KEY&token=$TRELLO_MEMBER_TOKEN"
TRELLO_LIST_ID=$(curl -s --request GET --url "$TRELLO_API/boards/$TRELLO_BOARD_ID/lists?$TRELLO_AUTH_QS" | $JQ ".[] | { name: .name, id: .id, match: (.name == \"$TRELLO_LIST_NAME\") } | select (.match) | .id" -r)
TRELLO_LIST=${TRELLO_LIST_ID:-$TRELLO_LIST_DEFAULT}
LIST_DATA=$(curl -s --request GET --url "$TRELLO_API/lists/$TRELLO_LIST/cards?$TRELLO_AUTH_QS")
LIST_LEN=$(echo $LIST_DATA | $JQ '. | length')
echo "Ideas Jar: ${LIST_LEN}"
echo "---"
if [ $LIST_LEN -gt 0 ]; then
for x in `seq 0 $((LIST_LEN-1))`; do
NAME=$(echo $LIST_DATA | $JQ ".[$x]| .name" -r)
LINK=$(echo $LIST_DATA | $JQ ".[$x]| .url" -r)
echo "$NAME|length=35 href=$LINK"
done
fi
@wildcard
Copy link
Author

Follow the instructions here for Trello auth https://github.com/weavenet/trello_cli#setup

You need to create a file in ~/.bitbar/.env with the following

TRELLO_BOARD_ID=""
TRELLO_LIST_NAME=""
TRELLO_LIST_DEFAULT=""

TRELLO_BOARD_ID the board you're looking into, you can get it from the url in Trello
TRELLO_LIST_NAME name of the list in the board
TRELLO_LIST_DEFAULT id of list to fallback to if no list is found in board

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment