-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtlmgri
More file actions
executable file
·44 lines (40 loc) · 1.09 KB
/
tlmgri
File metadata and controls
executable file
·44 lines (40 loc) · 1.09 KB
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
#!/bin/bash
set -e
if [[ "$#" -lt 1 ]]; then
echo "Usage: $0 [TLMGR OPTS] FILE"
exit 1
fi
#Chop of the last argument and save in FTS
FTS="${@: -1}"
set -- "${@:1:$(($#-1))}"
case "$FTS" in
*.*|latex|luatex|etex|pdflatex|pdfetex|dviluatex|dvilualatex|bibtex|mf|gftopk)
echo "Detected an extension or a familiar binary, try by exact file"
PKGS="$(tlmgr search --global --file "/$FTS" 2>/dev/null | grep -Po "^.*(?=:$)" || true)"
;;
*)
echo "Detected no extension, try by name"
PKGS="$(tlmgr search --global "$FTS" 2>/dev/null | grep -Po "^.*(?= - .*$)" || true)"
if [[ -z "$PKGS" ]]; then
echo "Sometimes a font metric is falsely given without the extension, trying with .tfm"
PKGS="$(tlmgr search --global --file "/$FTS.tfm" 2>/dev/null | grep -Po "^.*(?=:$)" || true)"
fi
;;
esac
if [[ -z "$PKGS" ]]; then
echo "No packages found..." >&2
exit 1
fi
if [[ $(wc -w <<< "$PKGS") -eq 1 ]]; then
tlmgr install "$@" "$PKGS"
else
select package in $PKGS; do
INDEX=1
for p in $PKGS; do
if [ $((INDEX++)) -eq $REPLY ]; then
tlmgr install "$@" "$p"
fi
done
break
done
fi