-
-
Save davemac/28a316259d68e85bad6b48daade59295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This script uses rsstail to retrieve latests entries from Reddit Popular rss feed | |
# and process them through awk. Each update shows a timestamp separator. | |
# | |
# It will work with most RSS feeds out there. | |
# | |
if [ $# -eq 1 ]; then | |
subreddit="r/$1" | |
elif [ $# -eq 2 ]; then | |
subreddit="user/$1/m/$2" | |
else | |
subreddit="r/popular" | |
fi | |
echo "Getting /$subreddit" | |
rsstail -rlH -u https://www.reddit.com/$subreddit/.rss | awk ' | |
BEGIN { | |
ResetColor = "\033[0m" | |
BrightColor = "\033[1;33m" | |
DarkColor = "\033[1;30m" | |
last_update = systime() | |
} | |
/^Title:/ { | |
title = $0 | |
sub(/Title:/, "", title) | |
} | |
/^Link:/ { | |
link = $0 | |
sub(/Link:/, "", link) | |
} | |
title && link { | |
# timestamp spam protection (30 seconds) | |
if (systime() - last_update >= 30) { | |
print DarkColor "---[ " strftime("%H:%M") " ]-------------" ResetColor | |
print "" | |
last_update = systime() | |
} | |
print BrightColor title ResetColor | |
print DarkColor link ResetColor | |
print "" | |
title = link = "" | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment