-
Notifications
You must be signed in to change notification settings - Fork 0
/
bibkeys.sh
executable file
·75 lines (65 loc) · 1.4 KB
/
bibkeys.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
# script to manage .bib files. This script uses bibtool. The official
# homepage is
HOMEPAGE=http://www.gerd-neugebauer.de/software/TeX/BibTool
# documentation:
DOCURL=http://www.gerd-neugebauer.de/software/TeX/BibTool/bibtool.pdf
# Some resources files for bibtool.
write_keygen_resource () {
# see page of the documentation
cat > "$1" <<EOF
fmt.name.title = "."
key.format = {
{
%-2n(author)
# %-2n(editor)
}
{
%s($fmt.name.title) %-1T(title)
# %s($fmt.name.title) %-1T(booktitle)
#
}
}
#
{
{
%s($fmt.name.title) %-1T(title)
# %s($fmt.name.title) %-1T(booktitle)
}
}
# %s($default.key)
EOF
}
help () {
local file=~/doc/bibtool.pdf
local url=$DOCURL
if [ -r $file ]; then
open $file
else
wget -O $file $url
open $file
fi
}
sort_bibs () {
bibtool -s \
-- 'sort.format="%N(author)"' \
-- 'sort.format="%N(editor)"' \
"$@"
}
keygen () {
local tmp=$(mktemp -t $(basename "$0").XXXX)
write_keygen_resource "$tmp"
bibtool -r "$tmp" "$@"
rm "$tmp"
}
#while getopts h FLAG; do
# case $FLAG in
# h) help; exit;;
# esac
#done
#exit
#if [ $# -eq 0 ]; then
# bibtool -f '%-1n(author)%-4d(year)%-T(title)'
#else
# bibtool -f '%-1n(author)%-4d(year)%-T(title)' "$@"
#fi | iconv -f UTF8 -t LATIN1 | bibtool -r iso2tex | iconv -f LATIN1 -t UTF8 | expand