Last active
October 13, 2019 20:17
-
-
Save jvalrog/101f57cf9294e9410f69b95a9a78e6ae to your computer and use it in GitHub Desktop.
This file contains 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. | |
# | |
rsstail -rlH -u https://www.reddit.com/r/popular/.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