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)"
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`"