-
Notifications
You must be signed in to change notification settings - Fork 0
/
tconfig
33 lines (25 loc) · 1.21 KB
/
tconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/bash
####################################################################################################
# Set DEFAULT_BIBDIR to the directory containing the `ref.bib` file and the `literature` directory.
#DEFAULT_BIBDIR=
####################################################################################################
# If DEFAULT_BIBDIR is not set above, then it will be set to the shortest path that contains both
# a file `ref.bib` and a directory `literature`.
if [[ -z "$DEFAULT_BIBDIR" ]] ; then
DEFAULT_BIBDIR=$(find "$HOME" -type d -path "*/bibliographie" -exec test -f '{}'/ref.bib -a -d '{}'/literature \; -print | sort -n | head -1)
fi
# If DEFAULT_BIBDIR is still not set, then it is set to the following value.
if [[ -z "$DEFAULT_BIBDIR" ]] ; then
DEFAULT_BIBDIR="$HOME/Bureau/bibliographie"
fi
if ! [[ -d "$DEFAULT_BIBDIR" ]] ; then
printf "\nDEFAULT_BIBDIR does not exist. Its current value is\n\n%s\n\nSet it properly.\n\n" "$DEFAULT_BIBDIR"
exit 1
fi
export DEFAULT_BIBDIR
mkdir -p "$DEFAULT_BIBDIR"
export DEFAULT_BIBFILE="$DEFAULT_BIBDIR/ref.bib"
export DEFAULT_REFDIR="$DEFAULT_BIBDIR/literature"
mkdir -p "$DEFAULT_REFDIR"
export REFDIR="$DEFAULT_REFDIR"
mkdir -p "$REFDIR"