Last active
February 10, 2020 08:42
-
-
Save afragen/748e4780b6057d4c41cf9e466557042a to your computer and use it in GitHub Desktop.
For use with Local by Flywheel (Pressmatic) Volumes Addon to create symlinks for better IDE integration
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 | |
# Usage: | |
# | |
# local-symlink.sh sitename -- add symlinks | |
# | |
# The value for sitename must match the folder you have for the site. | |
# | |
# Requires Local by Flywheel Volumes Add-on | |
# https://github.com/getflywheel/local-addon-volumes | |
# | |
# You MUST add each item in your plugins, mu_plugins, and themes in as a local addon path. | |
# Yes it sucks | |
# | |
# Thanks Ipstenu! | |
# case patterns are sitename(s) | |
case "$1" in | |
single-test ) | |
plugins=( | |
'github/add-custom-header-images' | |
'github/embed-pdf-viewer' | |
'github/github-updater' | |
'github/github-updater-additions' | |
'github/http-debug-info' | |
'github/local-development' | |
'github/the-events-calendar-category-colors' | |
'github/title-capitalization-for-wordpress' | |
'github/test-wcphx' | |
) | |
themes=() | |
mu_plugins=() | |
;; | |
* ) | |
echo "There is no site named '$1' to sync." | |
exit 1 | |
;; | |
esac | |
# Change these to your setup. | |
# By default, Local is installed in /Users/YOURNAME/Local Site | |
devsource="/Users/afragen/Documents" | |
local_path="/Users/afragen/Local Sites" | |
# You probably won't need to change these, unless WP is in a subfolder | |
docker_plugin_path="app/public/wp-content/plugins" | |
docker_mu_plugin_path="app/public/wp-content/mu_plugins" | |
docker_theme_path="app/public/wp-content/themes" | |
# Do not edit below this line | |
devsites=( $1 ) | |
for site in ${devsites[@]}; do | |
# Copy Plugins | |
for plugin in ${plugins[@]}; do | |
# if not symlink exists, force make symlink | |
if [[ ! -h "$local_path"/${site}/$docker_plugin_path/${plugin##*/} ]]; then | |
ln -sF $devsource/${plugin} "$local_path"/${site}/$docker_plugin_path | |
echo ${plugin##*/} 'symlink created' | |
fi | |
done | |
# Copy Themes | |
for theme in ${themes[@]}; do | |
# if not symlink exists, force make symlink | |
if [[ ! -h "$local_path"/${site}/$docker_theme_path/${theme##*/} ]]; then | |
ln -sF $devsource/${theme} "$local_path"/${site}/$docker_theme_path | |
echo ${theme##*/} 'symlink created' | |
fi | |
done | |
# Copy MU Plugins | |
for mu_plugin in ${mu_plugins[@]}; do | |
# if not symlink exists, force make symlink | |
if [[ ! -h "$local_path"/${site}/$docker_mu_plugin_path/${mu_plugin##*/} ]]; then | |
ln -sF $devsource/${mu_plugin} "$local_path"/${site}/$docker_mu_plugin_path | |
echo ${mu_plugin##*/} 'mu_plugin symlink created' | |
fi | |
done | |
done |
Modifications inspired by @Ipstenu https://gist.github.com/Ipstenu/f378eaf3779546d385ca7836bc87abc7
Updated and simplified. Now doesn't delete but checks to see if a symlink already exists and creates a symlink where one doesn't. If forcibly over-writes any other file that exists in that location, like a shared folder.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will need to modify this script to use your file paths and add your repo slugs.
After the plugins or themes are added via the Volumes Addon, simply run this modified script and symlinks with replace the created synced folders that LbF creates.
The
delete
parameter will remove anything that might be in the file paths designated in the script.