Skip to content

Instantly share code, notes, and snippets.

@papaeye
Created May 16, 2015 06:51
Show Gist options
  • Save papaeye/1fd8df4146742f4da055 to your computer and use it in GitHub Desktop.
Save papaeye/1fd8df4146742f4da055 to your computer and use it in GitHub Desktop.
Generate MacTeX uninstall script
#!/bin/bash
# https://tug.org/mactex/uninstalling.html
echo "# Uninstall TeX"
echo "rm -rf /usr/local/texlive"
echo "# Uninstall GUI Applications"
echo "rm -rf /Applications/TeX"
echo "# Uninstalling the TeX Distribution Data Structure"
echo "rm -rf /Library/TeX"
echo "rm -rf /Library/PreferencePanes/TeXDistPrefPane.prefPane"
## Uninstall Ghostscript
#
# MacTeX uninstaller script based on pkgutil command
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
#
# https://gist.github.com/uchida/4632662
# https://github.com/kusm/dotfiles/blob/master/mactex-uninstaller
IFS='
'
for pkg in $(pkgutil --pkgs | grep org.tug.mactex.ghostscript); do
volume="$(pkgutil --pkg-info $pkg | grep volume | cut -d ' ' -f 2-)"
location="$(pkgutil --pkg-info $pkg | grep location | cut -d ' ' -f 2-)"
echo "# Uninstall $pkg"
for file in $(pkgutil --files "$pkg" | tail -r); do
path="$volume$location/$file"
if [ -f "$path" ] ; then
echo "rm -f \"$path\""
elif [ -d "$path" ] ; then
echo "rmdir \"$path\""
fi
done
done
for pkg in $(pkgutil --pkgs | grep org.tug.mactex); do
echo "pkgutil --forget \"$pkg\""
done
@mzaksana
Copy link

Cool, I need to add more chain like : ./mactex-uninstaller-sh | tr -s '="/" > remove-mactex.sh, cuz multislash that generated by script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment