Skip to content

Instantly share code, notes, and snippets.

@vermiculus
Created December 19, 2015 13:38
Show Gist options
  • Save vermiculus/b95e0272e744359cdce2 to your computer and use it in GitHub Desktop.
Save vermiculus/b95e0272e744359cdce2 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Run as sudo
if [ "$EUID" -ne 0 ] ; then
>&2 echo "Please run as sudo."
exit 1
fi
if [ -z "$1" ] ; then
read -p "Package name: " PKG
else
PKG="$1"
fi
if ! tlmgr install $PKG 2>&1 1>/dev/null | grep 'not present'; then
echo "Installed via tlmgr."
exit 0
else
echo "Installing manually with wget/latex/texhash."
fi
pushd . >/dev/null
ltx="$HOME/Library/texmf/tex/latex"
echo "Installing into $ltx/$PKG"
mkdir -p "$ltx"
cd "$ltx"
wget "mirrors.ctan.org/macros/latex/contrib/$PKG.zip"
unzip "$PKG.zip" && rm "$PKG.zip"
cd $PKG
latex $PKG.ins
popd > /dev/null
texhash
echo
echo
echo "Package installed into"
kpsewhich "$PKG.sty"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment