summaryrefslogtreecommitdiff
path: root/plugins/lando/lando.plugin.zsh
diff options
context:
space:
mode:
authorJoshua Bedford <joshua@joshuabedford.com>2020-10-09 16:13:00 -0500
committerGitHub <noreply@github.com>2020-10-09 23:13:00 +0200
commit4cd5f7f9202bd062871662836ea837c9abea6e5d (patch)
tree1d79cc6adfbefbe206d7dbd7a59afa3b804a07f6 /plugins/lando/lando.plugin.zsh
parenta5e706d749e4218820391cb7ea374c6ddd248933 (diff)
downloadzsh-4cd5f7f9202bd062871662836ea837c9abea6e5d.tar.gz
zsh-4cd5f7f9202bd062871662836ea837c9abea6e5d.tar.bz2
zsh-4cd5f7f9202bd062871662836ea837c9abea6e5d.zip
Add lando plugin (#8748)
Co-authored-by: Joshua Bedford <joshua.bedford@hurstreview.com> Co-authored-by: Marc Cornellà <marc.cornella@live.com>
Diffstat (limited to 'plugins/lando/lando.plugin.zsh')
-rw-r--r--plugins/lando/lando.plugin.zsh40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/lando/lando.plugin.zsh b/plugins/lando/lando.plugin.zsh
new file mode 100644
index 000000000..aa74c9924
--- /dev/null
+++ b/plugins/lando/lando.plugin.zsh
@@ -0,0 +1,40 @@
+# Settings
+: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
+: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
+
+# Enable multiple commands with lando.
+function artisan \
+ composer \
+ drush \
+ gulp \
+ npm \
+ wp \
+ yarn {
+ if checkForLandoFile; then
+ lando "$0" "$@"
+ else
+ command "$0" "$@"
+ fi
+}
+
+# Check for the file in the current and parent directories.
+checkForLandoFile() {
+ # Only bother checking for lando within the Sites directory.
+ if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
+ # Not within $LANDO_ZSH_SITES_DIRECTORY
+ return 1
+ fi
+
+ local curr_dir="$PWD"
+ # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
+ while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
+ if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
+ return 0
+ fi
+ curr_dir="${curr_dir:h}"
+ done
+
+ # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
+ # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
+ return 1
+} \ No newline at end of file