Live data from Hacker News

Ask HN: How would you improve this bash oneliner for deleting tweets?

news.ycombinator.com

1–10 of 27 posts

Ask HN: How would you improve this bash oneliner for deleting tweets?

#1
Many people use tweet deletion services, which periodically remove everything from their Twitter timeline; I wondered if it could be done from a Bash command line.

I wrote up my experiences as an explainer for nontechnical people: https://jamiehall.cc/2020/03/10/delete-all-your-tweets-with-...

TL;DR, here is the oneliner I've been using:

  $ twurl "/1.1/statuses/user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&count=200
    &max_id=$(
      twurl '/1.1/statuses/user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&count=200&include_rts=1'
     | jq -c -r '.[] | .id_str' | head -10 | tail -1)
    &include_rts=1"
   | jq -c -r '.[] | .id_str' 
   | parallel -j 10 -a - twurl -X POST /1.1/statuses/destroy/{1}.json
   > /dev/null
[Edit: I've put line breaks in there to make it more legible.]

I'm curious if it's possible to do better. In particular: could this be more elegant? Is it possible to do it using common built-ins, instead of twurl and jq?

Any suggestions or improvements would be very welcome!

Re: Ask HN: How would you improve this bash oneliner for deleting tweets?

#2
You might consider putting this in a GitHub Gist, sharing the link for it, and accept comments and improvements within the Gist comments functionality.

This would also allow others to fork your code to improve upon or keep a copy for themselves.

Re: Ask HN: How would you improve this bash oneliner for deleting tweets?

#4
post #3

Not a Twitter user here, but would this delete retweets by others of your tweets? Those might include tweets that you'd most want to delete. As well as ones that you'd most want to retain, for that matter.

Yes, it takes care of that; if someone has retweeted you with a comment, the thing they're commenting on is replaced with "This tweet is no longer available." (Obviously, it's no defence against people screenshotting your tweet, manually copy-pasting what you said, etc etc.)

Re: Ask HN: How would you improve this bash oneliner for deleting tweets?

#5

You might consider putting this in a GitHub Gist, sharing the link for it, and accept comments and improvements within the Gist comments functionality. This would also allow others to fork your code to improve upon or keep a copy for themselves.

Great idea, thanks! https://gist.github.com/nerdcha/3e811ef28d04561f73337e46267a...

Re: Ask HN: How would you improve this bash oneliner for deleting tweets?

#7
You could improve it by making it not a one-liner! Usually making it a multiple-liner can improve readability. And unless you're typing it into the command line directly everytime you run it (as opposed to putting it in a file that you invoke) it doesn't really matter how many lines it has.

Re: Ask HN: How would you improve this bash oneliner for deleting tweets?

#9
post #3

Not a Twitter user here, but would this delete retweets by others of your tweets? Those might include tweets that you'd most want to delete. As well as ones that you'd most want to retain, for that matter.

Yes, it takes care of that; if someone has retweeted you with a comment, the thing they're commenting on is replaced with "This tweet is no longer available." (Obviously, it's no defence against people screenshotting your tweet, manually copy-pasting what you said, etc etc.)

alright

Re: Ask HN: How would you improve this bash oneliner for deleting tweets?

#10
post #3

Not a Twitter user here, but would this delete retweets by others of your tweets? Those might include tweets that you'd most want to delete. As well as ones that you'd most want to retain, for that matter.

Yes, it takes care of that; if someone has retweeted you with a comment, the thing they're commenting on is replaced with "This tweet is no longer available." (Obviously, it's no defence against people screenshotting your tweet, manually copy-pasting what you said, etc etc.)

ok
Post reply on HN