aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-06-01 07:19:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-06-01 07:19:59 -0300
commit49869d77725fceebccf7fb54559932cae8026b0e (patch)
tree564d5660ac28d393530f6bb12992c5f7afc02698
parent9678b09a5824d84df8be30f7e43f693b6c097111 (diff)
downloadscripts-49869d77725fceebccf7fb54559932cae8026b0e.tar.gz
scripts-49869d77725fceebccf7fb54559932cae8026b0e.tar.bz2
Feat: show: add --details command to show BibTeX entries
-rwxr-xr-xshow14
1 files changed, 14 insertions, 0 deletions
diff --git a/show b/show
index 8dcdb06..b0e983d 100755
--- a/show
+++ b/show
@@ -7,6 +7,7 @@
PROGRAM="$0"
BASENAME="`basename $0`"
DOCS="$HOME/data/doc"
+BIBLIO="$DOCS/bibliographies"
FILELIST=".filelist"
LIST="$DOCS/$FILELIST"
DOC_PATTERN=".*\.(txt|doc|docx|rtf|pdf|sxc|csv|odt|odf|ods|xls|xlsx|ppt|epub|mobi|djvu|lit)"
@@ -68,6 +69,19 @@ fi
if [ "$ARG" == "--search" ]; then
shift
grep -i -- "$*" $LIST
+elif [ "$ARG" == "--details" ]; then
+ shift
+ entry="`echo $* | sed -e 's/^@//'`"
+ if grep -qiR -- "$entry" $BIBLIO; then
+ grep -iR -- "$entry" $BIBLIO | cut -d : -f 1 | while read file; do
+ echo "At $file:"
+ echo ""
+ # Thanks https://tex.stackexchange.com/questions/28506/how-to-use-a-command-line-tool-to-extract-a-bibtex-reference-that-contains-a-sea
+ awk -v RS='\n@' "/${entry}/" $file
+ done
+ else
+ find $DOCS -name ${1}.bib -exec cat {} \;
+ fi
elif [ "$ARG" == "--watch" ]; then
# Convert symlink to full path and start inotifywait loop
folder="`readlink -f $DOCS`"