diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-10-13 11:28:42 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-10-13 11:28:42 +1300 |
commit | 0417c448fce3bd98522b66f89b4b5219aaf40758 (patch) | |
tree | 17f71c881beaaba9dfd5601cae602fce8e78fbdc | |
download | rdt-master.tar.gz rdt-master.zip |
-rw-r--r-- | README.markdown | 25 | ||||
-rwxr-xr-x | rdt | 11 | ||||
-rwxr-xr-x | rdtm | 8 |
3 files changed, 44 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..e0cd7da --- /dev/null +++ b/README.markdown @@ -0,0 +1,25 @@ +rdt +=== + +Spit out the titles and links for the front page of a given subreddit, +including specifying "rising", "new" etc. + +Just two horrible little shell scripts...but they work! + +* `rdt` +* `rdt programming` +* `rdt programming rising` +* `rdtm programming linux vim` + +Requires [`curl`][1], [`pup`][2], and [`jq(1)`][3]. + +License +------- + +Copyright (c) [Tom Ryder][4]. Distributed under an [MIT License][5]. + +[1]: https://curl.haxx.se/ +[2]: https://github.com/ericchiang/pup +[3]: https://stedolan.github.io/jq/ +[4]: https://sanctum.geek.nz/ +[5]: https://www.opensource.org/licenses/MIT @@ -0,0 +1,11 @@ +#!/bin/sh +# Get the titles of posts in a given subreddit (defaults to /r/all) +curl -A Mozilla https://reddit.com/r/"${1:-all}"/"${2:+"$2"/}".compact | +pup -p 'p.title > a' 'json{}' | +jq -M -r '.[] | .text,.href' | +sed ' +/^http/{ + s/^/ </ + s/$/>/ +} +' @@ -0,0 +1,8 @@ +#!/bin/sh +[ "$#" -gt 0 ] || exit 2 +for sr ; do + printf '/r/%s:\n\n' "$sr" + rdt "$sr" | sed 's/^/ /' || ex=1 + printf '\n' +done +ex=${ex:-0} |