Skip to content

Instantly share code, notes, and snippets.

@CrookedNumber
Last active November 16, 2020 17:36
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CrookedNumber/8857003 to your computer and use it in GitHub Desktop.
Save CrookedNumber/8857003 to your computer and use it in GitHub Desktop.
Sample bash script to add tickets to Trello
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage is: $0: <board> <title>"
echo "For example: trello wedding 'Taste cakes'"
exit 1
fi
if [ $1 != 'work' -a $1 != 'homeprojects' -a $1 != 'wedding' ]
then
echo 'Bad board'
exit 1
fi
if [ $1 = 'work' ]
then
listid='edlkdj238742847qldelqjhljeh'
fi
if [ $1 = 'homeprojects' ]
then
listid='kdjqlkdhj23o2kj2lq;edjk2edkj2'
fi
if [ $1 = 'wedding' ]
then
listid='ekjwlekfjeqlkwelk293294829348'
fi
# replace spaces in name with + (or else http call will fail)
name=$2
safe_name=$(echo $name|tr ' ' '+')
data="name="$safe_name"&due=null&idList="$listid"&token=YourTrelloToken&key=YourTrelloKey"
# The following curl will throw away response json, and display just status code (200 == two thumbs up!)
curl -s -o /dev/null -w "%{http_code}\\n" --data $data https://api.trello.com/1/cards
@Narvey
Copy link

Narvey commented Sep 22, 2016

This version is slightly more maintainable by using case/esac so that you only have to swap out list names and IDs (and KEY/TOKEN) once for a functional script (though you would have to do a little more legwork for documentation, the functionality is all there with just those swaps).

I also made safe_name a little safer by escaping ampersands (&s) so you don't unintentionally pull a Bobby Tables when you send data that has ampersands.

Feel free to incorporate the code from that as a new revision of the gist (since I accidentally submitted it as anonymous). As a bonus, if you use GitHub's Add file button, you can include the bash script in the same gist as the instructions (since they show on Google top 10), and update step #9 real quick to include the token.

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