Skip to content

Instantly share code, notes, and snippets.

@jonlabelle
Last active December 26, 2015 04:28
Show Gist options
  • Save jonlabelle/7093017 to your computer and use it in GitHub Desktop.
Save jonlabelle/7093017 to your computer and use it in GitHub Desktop.
A Bash function that updates Sublime Text packages which aren't under package control, and have git repositories.
# update all non-sublime package control packages (osx)
function update_sublimetext_packages()
{
echo ""
echo "==> Updating Sublime Text Packages"
echo ""
local cwd=$(pwd)
local subl_pkgs_dir=~/Library/Application\ Support/Sublime\ Text\ 3/Packages
local repo=
cd "${subl_pkgs_dir}"
find . -name '.git' -type d -maxdepth 2 -print0 | while read -d $'\0' repository;
do
repo=`dirname "${repository}"`
echo -e -n "- \033[0;32m`basename "${repo}"`\033[0m: "
cd "${repo}" && git pull 2>/dev/null
if [ $? -ne 0 ]; then
echo -e "\nERROR pulling from: \033[0;31m`basename "${repo}"`\033[0m"
echo "Aborting!"
cd "${cwd}"
return
fi
done
cd "${cwd}"
echo ""
echo "Done."
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment