@@ -30,31 +30,6 @@ GPG_COMMAND="gpg2"
3030default_commit_message=" Add new entry"
3131useParallel=true
3232
33- # configuration file to override the above defined variables.
34- if [ -f .callioperc ]
35- then
36- source .callioperc
37- else
38- echo " No .callioperc file found. Creating file with empty fields."
39- echo " Please fill in the necessary information."
40- echo " It will be used in subsequent runs."
41- echo " ProjectName=\"\" " > .callioperc
42- echo " author=\"\" " >> .callioperc
43- echo " bibsrc=\"\" " >> .callioperc
44- echo " encryptionId=\"\" " >> .callioperc
45- exit 0
46- fi
47-
48- latest_diary_entry=$( find $diary_dir -name " ????-??-??.tex" -o -name " ????-??-??.tex.gpg" | sort | tail -1)
49- latest_pdf_entry=$( find $pdf_dir -name " ????-??-??.pdf" -o -name " ????-??-??.pdf.gpg" | sort | tail -1)
50- todays_entry=" $year -$month -$day .tex"
51- latest_entry_year=${latest_diary_entry: 6: 4}
52- latest_diary_entry_file=${latest_diary_entry: 11}
53- latest_pdf_year=${latest_pdf_entry: 5: 4}
54- latest_pdf_entry_file=${latest_pdf_entry: 9}
55-
56- # echo "latest diary entry is: $latest_diary_entry"
57- # echo "latest pdf entry: $latest_pdf_entry"
5833
5934add_entry ()
6035{
@@ -654,13 +629,43 @@ usage ()
654629 Master script file that provides functions to maintain a journal using LaTeX.
655630 Please report issues and request features at ${UPSTREAM_URL} .
656631
632+ CONFIGURATION:
633+
634+ Each journal needs a configuration file that lives in the project root folder called .callioperc:
657635
658- OPTIONS:
636+ ProjectName=" myproject" > .callioperc
637+ author=" my name" >> .callioperc
638+ bibsrc=" /path/to/bibliography.bib" >> .callioperc
639+ encryptionId=" encryption_key_id" >> .callioperc
640+
641+ This file is sourced by the script, so please do not use special characters such as '|' that the shell may interpret.
642+
643+ GLOBAL JOURNAL LIST:
644+
645+ To use the -j flag to list " configured" journals, you can create a ~/.callioperc.journals file.
646+ It is a line by line list of journals that you want the script to be aware of.
647+ This doesn't do anything fancy, it only lists the paths to these journals so that you can get to them quicker.
648+ The file should be of the form:
649+
650+ journal1=/path/to/journal1/
651+ journal2=/path/to/journal2/
652+
653+ Please do not use quotes here, and please avoid spaces.
654+
655+ GLOBAL OPTIONS:
659656
660657 -h Show this message and quit
661658
662659 -H Print version and exit
663660
661+ -j <journal name>
662+ show path to journal name: requires setting a global .callioperc.journals file
663+
664+
665+ JOURNAL OPTIONS:
666+
667+ These options need a .callioperc configuration file
668+
664669 -t Add new entry for today
665670
666671 -l Compile latest entry
@@ -728,124 +733,168 @@ usage ()
728733 -I <non image file path>
729734 imports the non-image into the diary extra files folder and renames it " < timestamp> .extension"
730735
731- -j <journal name>
732- show path to journal name: requires setting a global .callioperc.journals file
733-
734736EOF
735737
736738}
737739
738- if [ " $# " -eq 0 ]; then
739- usage
740- exit 0
741- fi
740+ # configuration file to override the defined variables.
741+ if [ -f .callioperc ]
742+ then
743+ if [ " $# " -eq 0 ]; then
744+ usage
745+ exit 0
746+ fi
742747
743- while getopts " evLltca:A:hHp:s:E:V:k:CG:g:xmi:I:j:" OPTION
744- do
745- case $OPTION in
746- t)
747- add_entry
748- exit 0
749- ;;
750- L)
751- list_latest
752- exit 0
753- ;;
754- e)
755- edit_latest
756- exit 0
757- ;;
758- v)
759- view_latest
760- exit 0
761- ;;
762- l)
763- compile_latest
764- exit 0
765- ;;
766- c)
767- compile_today
768- exit 0
769- ;;
770- a)
771- year_to_compile=$OPTARG
772- create_anthology
773- exit 0
774- ;;
775- A)
776- year_to_compile=$OPTARG
777- view_anthology
778- exit 0
779- ;;
780- h)
781- usage
782- exit 0
783- ;;
784- H)
785- echo " ${VERSION} "
786- exit 0
787- ;;
788- p)
789- year_to_compile=$OPTARG
790- compile_all
791- exit 0
792- ;;
793- s)
794- entry_to_compile=$OPTARG
795- compile_specific
796- exit 0
797- ;;
798- E)
799- entry_to_edit=$OPTARG
800- edit_specific
801- exit 0
802- ;;
803- V)
804- entry_to_view=$OPTARG
805- view_specific
806- exit 0
807- ;;
808- k)
809- search_term=$OPTARG
810- search_diary
811- exit 0
812- ;;
813- C)
814- compile_latest
815- commit_changes
816- exit 0
817- ;;
818- m)
819- commit_changes
820- exit 0
821- ;;
822- G)
823- decrypt " $OPTARG "
824- exit 0
825- ;;
826- g)
827- encrypt " $OPTARG "
828- exit 0
829- ;;
830- x)
831- remove_unencrypted
832- exit 0
833- ;;
834- i)
835- add_extra_file " image" " $OPTARG "
836- exit 0
837- ;;
838- I)
839- add_extra_file " other" " $OPTARG "
840- exit 0
841- ;;
842- j)
843- switch_journal " $OPTARG "
844- exit 0
845- ;;
846- ?)
847- usage
848- exit 0
849- ;;
850- esac
851- done
748+ source .callioperc
749+
750+ latest_diary_entry=$( find $diary_dir -name " ????-??-??.tex" -o -name " ????-??-??.tex.gpg" | sort | tail -1)
751+ latest_pdf_entry=$( find $pdf_dir -name " ????-??-??.pdf" -o -name " ????-??-??.pdf.gpg" | sort | tail -1)
752+ todays_entry=" $year -$month -$day .tex"
753+ latest_entry_year=${latest_diary_entry: 6: 4}
754+ latest_diary_entry_file=${latest_diary_entry: 11}
755+ latest_pdf_year=${latest_pdf_entry: 5: 4}
756+ latest_pdf_entry_file=${latest_pdf_entry: 9}
757+
758+ #echo " latest diary entry is: $latest_diary_entry "
759+ #echo " latest pdf entry: $latest_pdf_entry "
760+ while getopts " evLltca:A:hHp:s:E:V:k:CG:g:xmi:I:j:" OPTION
761+ do
762+ case $OPTION in
763+ t)
764+ add_entry
765+ exit 0
766+ ;;
767+ L)
768+ list_latest
769+ exit 0
770+ ;;
771+ e)
772+ edit_latest
773+ exit 0
774+ ;;
775+ v)
776+ view_latest
777+ exit 0
778+ ;;
779+ l)
780+ compile_latest
781+ exit 0
782+ ;;
783+ c)
784+ compile_today
785+ exit 0
786+ ;;
787+ a)
788+ year_to_compile=$OPTARG
789+ create_anthology
790+ exit 0
791+ ;;
792+ A)
793+ year_to_compile=$OPTARG
794+ view_anthology
795+ exit 0
796+ ;;
797+ h)
798+ usage
799+ exit 0
800+ ;;
801+ H)
802+ echo " ${VERSION} "
803+ exit 0
804+ ;;
805+ p)
806+ year_to_compile=$OPTARG
807+ compile_all
808+ exit 0
809+ ;;
810+ s)
811+ entry_to_compile=$OPTARG
812+ compile_specific
813+ exit 0
814+ ;;
815+ E)
816+ entry_to_edit=$OPTARG
817+ edit_specific
818+ exit 0
819+ ;;
820+ V)
821+ entry_to_view=$OPTARG
822+ view_specific
823+ exit 0
824+ ;;
825+ k)
826+ search_term=$OPTARG
827+ search_diary
828+ exit 0
829+ ;;
830+ C)
831+ compile_latest
832+ commit_changes
833+ exit 0
834+ ;;
835+ m)
836+ commit_changes
837+ exit 0
838+ ;;
839+ G)
840+ decrypt " $OPTARG "
841+ exit 0
842+ ;;
843+ g)
844+ encrypt " $OPTARG "
845+ exit 0
846+ ;;
847+ x)
848+ remove_unencrypted
849+ exit 0
850+ ;;
851+ i)
852+ add_extra_file " image" " $OPTARG "
853+ exit 0
854+ ;;
855+ I)
856+ add_extra_file " other" " $OPTARG "
857+ exit 0
858+ ;;
859+ j)
860+ switch_journal " $OPTARG "
861+ exit 0
862+ ;;
863+ ?)
864+ usage
865+ exit 0
866+ ;;
867+ esac
868+ done
869+ else
870+ echo " WARNING: No .callioperc file found: so we are not in a journal folder."
871+ echo " WARNING: Not all options can be used"
872+ echo
873+
874+ if [ " $# " -eq 0 ]; then
875+ usage
876+ exit 0
877+ fi
878+
879+ while getopts " hHj:" OPTION
880+ do
881+ case $OPTION in
882+ h)
883+ usage
884+ exit 0
885+ ;;
886+ H)
887+ echo " ${VERSION} "
888+ exit 0
889+ ;;
890+ j)
891+ switch_journal " $OPTARG "
892+ exit 0
893+ ;;
894+ ?)
895+ usage
896+ exit 0
897+ ;;
898+ esac
899+ done
900+ fi
0 commit comments