lando.plugin.zsh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Settings
  2. : ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
  3. : ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
  4. # Enable multiple commands with lando.
  5. function artisan \
  6. composer \
  7. drush \
  8. gulp \
  9. npm \
  10. php \
  11. wp \
  12. yarn {
  13. if checkForLandoFile; then
  14. lando "$0" "$@"
  15. else
  16. command "$0" "$@"
  17. fi
  18. }
  19. # Check for the file in the current and parent directories.
  20. checkForLandoFile() {
  21. # Only bother checking for lando within the Sites directory.
  22. if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
  23. # Not within $LANDO_ZSH_SITES_DIRECTORY
  24. return 1
  25. fi
  26. local curr_dir="$PWD"
  27. # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
  28. while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
  29. if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
  30. return 0
  31. fi
  32. curr_dir="${curr_dir:h}"
  33. done
  34. # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
  35. # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
  36. return 1
  37. }