32 lines
1.1 KiB
Text
32 lines
1.1 KiB
Text
|
#!/usr/bin/env sh
|
||
|
# shows due entries of bibtex file passed in
|
||
|
# HACK: brittle! will break on various bibfile abnormities (even just on due date w/o priority)
|
||
|
# FIXME: reimplementation with real library needed
|
||
|
#
|
||
|
|
||
|
fields="due|priority|\bauthor\b|\btitle\b"
|
||
|
filterby="due"
|
||
|
|
||
|
main() {
|
||
|
# use system default bib file or passed argument
|
||
|
if [ -n "$1" ]; then
|
||
|
file="$1"
|
||
|
elif [ -n "$BIBFILE" ]; then
|
||
|
file="$BIBFILE"
|
||
|
else
|
||
|
echo "Requires a bibtex file as argument."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# filter all entries for those containing filterby field (default: due)
|
||
|
# retain values of all fields mentioned in fields variable
|
||
|
entries=$(grep -E "^@|$fields" "$file" | awk 1 ORS=' ' | sed -E 's/@\w+\{/\n/g' | grep $filterby | tail -n +2 | sed -E 's/(,\s+(\w+)\s+=\s+|,\s*$)/\t/g' | awk -F'\t' '{ print $4 "\t" $5 "\t" $2 "\t" $3 "\t" $1 }')
|
||
|
|
||
|
# prettify and sort the entries for display (remove {}, order by date,prio,author,title)
|
||
|
entries=$(echo "$entries" | awk -F'\t' '{ gsub(/{/,""); gsub(/}/,""); gsub(/prio/,"",$2) } { print $1 " (" $2 "): " $3 " -- " $4 " (" $5 ")"}' | sort)
|
||
|
|
||
|
echo "$entries"
|
||
|
}
|
||
|
|
||
|
main "$@"
|