Last active
November 15, 2016 18:52
-
-
Save ksaa/254ebd26577b83bfeb6be557c97d87d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Let's get some color going! | |
red=$'\e[1;31m' | |
grn=$'\e[1;32m' | |
end=$'\e[0m' | |
bold=$(tput bold) | |
# Find Box Sync folder | |
boxtemplates=$(<$HOME/Library/Application\ Support/Box/Box\ Sync/sync_root_folder.txt) | |
# Sketch folders | |
sketchdir1="$HOME/Library/Application Support/com.bohemiancoding.sketch3/" | |
sketchdir2="$HOME/Library/Containers/com.bohemiancoding.sketch3/" | |
sketchdir3="$HOME/Library/Containers/com.bohemiancoding.sketch3.beta/" | |
# Template files | |
dlscolor="DLSColor" | |
dlstype="DLSTypography" | |
dlsicons="DLSIcons" | |
dlsphone="DLSComponents_Phone" | |
dlstablet="DLSComponents_Tablet" | |
dlsweb="DLSComponents_Web" | |
dlsscratch="ScratchComponents_Native" | |
# Graphics :) | |
printf "\n" | |
printf " | |
${grn} | |
I n s t a l l i n g . . . \n | |
_____ _ _____ | |
| __ \| | / ____| | |
| | | | | | (___ | |
| | | | | \___ \\ | |
| |__| | |____ ____) | | |
|_____/|______|_____/ | |
\n${end} | |
" | |
printf " " | |
sleep 0.5 | |
# cd to cwd of the script (presumably in it's proper location) | |
cd "$(dirname "$0")" | |
if [ -d "${boxtemplates}" ]; then | |
# Install for App Store/Stable Sketch | |
if [ -d "${sketchdir1}" ]; then | |
path="${sketchdir1}" | |
mkdir -p "${path}Templates"; | |
ln -shf "${boxtemplates}/${dlsphone}.sketch" "${path}Templates/_DLS _Phone.sketch"; | |
ln -shf "${boxtemplates}/${dlstablet}.sketch" "${path}Templates/_DLS _Tablet.sketch"; | |
ln -shf "${boxtemplates}/${dlsweb}.sketch" "${path}Templates/_DLS _Web.sketch"; | |
ln -shf "${boxtemplates}/${dlscolor}.sketch" "${path}Templates/_DLS Color.sketch"; | |
ln -shf "${boxtemplates}/${dlsicons}.sketch" "${path}Templates/_DLS Icons.sketch"; | |
ln -shf "${boxtemplates}/${dlstype}.sketch" "${path}Templates/_DLS Typography.sketch"; | |
ln -shf "${boxtemplates}/${dlsscratch}.sketch" "${path}Templates/_Scratch Native.sketch"; | |
ln -shf "${boxtemplates}/${dlsphone}.png" "${path}Templates/_DLS _Phone.png"; | |
ln -shf "${boxtemplates}/${dlstablet}.png" "${path}Templates/_DLS _Tablet.png"; | |
ln -shf "${boxtemplates}/${dlsweb}.png" "${path}Templates/_DLS _Web.png"; | |
ln -shf "${boxtemplates}/${dlscolor}.png" "${path}Templates/_DLS Color.png"; | |
ln -shf "${boxtemplates}/${dlsicons}.png" "${path}Templates/_DLS Icons.png"; | |
ln -shf "${boxtemplates}/${dlstype}.png" "${path}Templates/_DLS Typography.png"; | |
ln -shf "${boxtemplates}/${dlsscratch}.png" "${path}Templates/_Scratch Native.png"; | |
success=" Restart Sketch and you should have access to a new Sketch menu: ${bold}\"File > New From Template\".${end} Keep your Box folder synced to keep these updated.\n" | |
fi | |
if [ -d "${sketchdir2}" ]; then | |
path="${sketchdir2}Data/Library/Application Support/com.bohemiancoding.sketch3/" | |
mkdir -p "${path}Templates"; | |
ln -shf "${boxtemplates}/${dlsphone}.sketch" "${path}Templates/_DLS _Phone.sketch"; | |
ln -shf "${boxtemplates}/${dlstablet}.sketch" "${path}Templates/_DLS _Tablet.sketch"; | |
ln -shf "${boxtemplates}/${dlsweb}.sketch" "${path}Templates/_DLS _Web.sketch"; | |
ln -shf "${boxtemplates}/${dlscolor}.sketch" "${path}Templates/_DLS Color.sketch"; | |
ln -shf "${boxtemplates}/${dlsicons}.sketch" "${path}Templates/_DLS Icons.sketch"; | |
ln -shf "${boxtemplates}/${dlstype}.sketch" "${path}Templates/_DLS Typography.sketch"; | |
ln -shf "${boxtemplates}/${dlsscratch}.sketch" "${path}Templates/_Scratch Native.sketch"; | |
ln -shf "${boxtemplates}/${dlsphone}.png" "${path}Templates/_DLS _Phone.png"; | |
ln -shf "${boxtemplates}/${dlstablet}.png" "${path}Templates/_DLS _Tablet.png"; | |
ln -shf "${boxtemplates}/${dlsweb}.png" "${path}Templates/_DLS _Web.png"; | |
ln -shf "${boxtemplates}/${dlscolor}.png" "${path}Templates/_DLS Color.png"; | |
ln -shf "${boxtemplates}/${dlsicons}.png" "${path}Templates/_DLS Icons.png"; | |
ln -shf "${boxtemplates}/${dlstype}.png" "${path}Templates/_DLS Typography.png"; | |
ln -shf "${boxtemplates}/${dlsscratch}.png" "${path}Templates/_Scratch Native.png"; | |
success=" Restart Sketch and you should have access to a new Sketch menu: ${bold}\"File > New From Template\"${end} Keep your Box folder synced to keep these updated.\n" | |
fi | |
sleep 0.5 | |
printf "${grn}.${end}" | |
sleep 0.5 | |
printf "${grn}.${end}" | |
sleep 0.5 | |
printf "${grn}.${end}" | |
sleep 0.5 | |
printf "${grn}Done\n\n${end}" | |
sleep 1 | |
printf "${success}" | |
fi | |
# Disable autosaving in Sketch | |
#defaults write com.bohemiancoding.sketch3 enableAutoSaveAndVersions 0 | |
#printf "\n ${grn}Notice:${end} I've switched off AutoSave in Sketch, makes sure to manually save often.\n\n" | |
# Catch errors | |
if [ ! -d "${boxtemplates}" ]; then | |
printf "${red}Error:${end} I can't find the \"EPIC Templates\" folder. Log into the Box Web app and choose to Sync that folder.\n\n" | |
fi | |
if [ ! -d "${sketchdir1}" ] && [ ! -d "${sketchdir2}" ] && [ ! -d "${sketchdir3}" ]; then | |
printf "${red}Error:${end} Couldn't install the templates because I can't find Sketch App.\n\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment