Skip to content

Instantly share code, notes, and snippets.

@mxbees
Last active July 30, 2016 16:22
Show Gist options
  • Save mxbees/8f4b1e6b13c5d538c34c2bd64b97d722 to your computer and use it in GitHub Desktop.
Save mxbees/8f4b1e6b13c5d538c34c2bd64b97d722 to your computer and use it in GitHub Desktop.
Two bash scripts for commandline tweet threading.
#These are two scripts I use for creating tweet threads from the commandline.
#These rely on a rubygem, 't'. https://github.com/sferik/t which needs to installed for these scripts to work.
#first script is for tweeting, I have bash alias 'tt' that invokes this script. Its name 'tt.sh' on my machine
#!/bin/bash
t update "$1" | tail -n 1 | sed 's/Run\ `t\ delete\ status\ //' | sed 's/`\ to\ delete\.//' > /tmp/tweetid.txt
#second script is for taking the tweetid saved in /tmp/tweetid.txt file. You can obviously change where this
#file is saved. I call it 'tre.sh' and the bash alias is 'tre'.
#!/bin/bash
tweet_id=$(cat /tmp/tweetid.txt)
t reply $tweet_id "$1" | tail -n 1 | sed 's/Run\ `t\ delete\ status\ //' | sed 's/`\ to\ delete\.//' > /tmp/tweetid.txt
#So for use, you have to start with 'tt.sh' which sets the first tweet in the thread. Thereafter, you must use 'tre.sh'
#to create a thread. Since 'tre.sh' saves that tweet's ID, you get a nice chain with each tweet following the previous.
#Limitations: If you screw up a 'tre.sh' tweet, for example by using too many characters, you can see that the script
#always overwrites the 'tweetid.txt' file. So if your tweet fails, this will end up blank and break your
#tweet thread. Its annoying but this is still the easiest way I know to create threads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment