Skip to content

Instantly share code, notes, and snippets.

@aabmass
Last active November 6, 2019 22:50
Show Gist options
  • Save aabmass/259eaaf98ba5e0d6fe417e6f37405990 to your computer and use it in GitHub Desktop.
Save aabmass/259eaaf98ba5e0d6fe417e6f37405990 to your computer and use it in GitHub Desktop.
bash function (include in bashrc to work like an alias) to print a tweet from https://twitter.com/dog_feelings
function dogthought {
rand_val=$((1 + RANDOM % 10))
curl -s https://twitter.com/dog_feelings \
| xmllint --html -xpath "(/html/body/descendant::div[contains(@class, 'js-tweet-text-container')]/p[contains(@class, 'tweet-text')])[${rand_val}]/text()" - 2>/dev/null \
| cowsay -f <(curl -s https://gist.githubusercontent.com/aabmass/c4230d06daa7073d0fb537030ed7d05c/raw/960572ed504c576f58bb4d8d182f01a9aeb10f95/dog.cow)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment