config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit e4ac8a4f38a59fa9fae3857e1076266a43c4700d
parent 3fdae011dda0f7545490b8e14c0ec4b6eb5cc670
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu, 10 Sep 2020 09:32:28 -0700

Make more modular

does not chdir into $RSSTEXT directory.

no specified files now uses stdin instead of using all files.

Diffstat:
Mscripts/.local/bin/feed | 29++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/scripts/.local/bin/feed b/scripts/.local/bin/feed @@ -1,36 +1,29 @@ #!/usr/bin/env dash -# manage searching and viewing sfeed formatted files in $RSSTEXT directory. +# manage viewing sfeed formatted files. set -eu -# take sfeed formatted text returning html or plain-text. +# return html or plain-text from specified files or stdin +# format([file], ...) format() { awk -f `which sfeed.awk` $@ } -# return feeds in 'filename index: title` format +# return specified feeds, or stdin, formatted in 'filename index: title` +# show([file], ...) show() { awk -F"\t" '{ printf "%s %d: %s\n", FILENAME, FNR, $2 }' $@ } -# return feed filenames unless filename(s) specified in which case call show -list() -{ - if [ $# -eq 0 ]; then - ls -1 - else - show $@ - fi -} - -# returns the nth feed in all feeds or specified feeds +# return the nth feed in specified files or stdin +# nth(n, [file], ...) nth() { local n=$1 shift - for feed in ${@:-`ls -1`} + for feed in ${@:-''} do head -$n $feed | tail -n1 done @@ -40,11 +33,9 @@ if [ $# -gt 0 ]; then cmd=$1 shift fi - -cd $RSSTEXT case "${cmd:=}" in - -l) list $@;; + -l) show $@;; -n) nth $@ | format;; - *) egrep -Ri "$cmd" $@ | format;; + *) egrep -i "$cmd" $@ | format;; esac