commit d3125396486ffba3bf883927fc6f5995b0b9d379
parent 43dbbdf07922c024d1be5cf28da876c13d568291
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Sat, 13 Feb 2021 23:41:41 -0800
Many small improvements to the feed script
With the addition of the `view' command it can be used to format
sfeed text in a pipeline of unrelated utilities making it much more
useful. Formatting HTML is now done with lynx(1) instead of w3m(1)
as it produces more legible results when not in color. Additionally:
- Replace `\t' and `\n' with a single space
- Use the author field rather than filename in the `list' command
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/modules/scripts/.local/bin/feed b/modules/scripts/.local/bin/feed
@@ -7,17 +7,16 @@
# l[ist] List items
# i[tem] Display the nth item
# e[xpr] Display items matching an ERE
+# v[iew] Display all items
-fmt()
+view()
{
- awk -F'\t' '{ printf "From %s: %s\n\n%s", $7, $2, $4 }' $* |
- sed -e 's/\\t//g' -e 's/\\n//g' | w3m -T text/html -dump -O ASCII |
- command fmt
+ cut -f4 $* | sed 's/\\[tn]/ /g' | lynx -dump -stdin
}
list()
{
- awk -vOFS='\t' -F'\t' '{ print FILENAME, FNR, $2 }' $*
+ awk -vOFS='\t' -F'\t' '{ print $7, FNR, $2 }' $*
}
item()
@@ -28,12 +27,12 @@ item()
sed -n "$item { p
q
}" $feed
- done | fmt
+ done | view
}
expr()
{
- egrep -i $* | fmt
+ egrep -i $* | view
}
case $1
@@ -41,5 +40,6 @@ in
l|list) shift; list $*;;
i|item) shift; item $*;;
e|expr) shift; expr $*;;
+ v|view) shift; view $*;;
*) printf 'usage: %s [command] [arg...]\n' `basename $0` 1>&2; exit 1;;
esac