Skip to content

Instantly share code, notes, and snippets.

@iago-pssjd
Last active August 4, 2021 20:24
Show Gist options
  • Save iago-pssjd/aacb6f8f31cebde1ef7732625cf322eb to your computer and use it in GitHub Desktop.
Save iago-pssjd/aacb6f8f31cebde1ef7732625cf322eb to your computer and use it in GitHub Desktop.
Shell script to install LaTeX sty files from LaTeX packages on CTAN to Debian/Ubuntu
#!/bin/bash
# Process https://tex.stackexchange.com/a/1138
# set -x
if [ "$(id -u)" = "0" ]; then
echo "Please, avoid to run this script as root"
exit 1
fi
echo "Please, add the CTAN package you are interested in:"
read ctanpkg
pkgfile="$ctanpkg".zip
wget -P /tmp https://mirrors.ctan.org/macros/latex/contrib/$pkgfile
if [ -f "/tmp/$pkgfile" ]; then
unzip -o /tmp/$pkgfile -d /tmp
else
echo "Download did not have the expected output."
exit 1
fi
rm /tmp/$pkgfile
styff="$(find /tmp/$ctanpkg -name *.sty)"
texhomedir="$(kpsewhich -var-value=TEXMFHOME)"
for styfile in $styff; do
if [ -f $styfile ]; then
mkdir -p "$texhomedir"/tex/latex/local
cp $styfile "$texhomedir"/tex/latex/local
texhash "$texhomedir"
echo "$styfile installation succeed"
else
exit 1
fi
done
rm -r /tmp/$ctanpkg
# set +x
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment