lando.plugin.zsh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. wp \
  11. yarn {
  12. if checkForLandoFile; then
  13. lando "$0" "$@"
  14. else
  15. command "$0" "$@"
  16. fi
  17. }
  18. # Check for the file in the current and parent directories.
  19. checkForLandoFile() {
  20. # Only bother checking for lando within the Sites directory.
  21. if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
  22. # Not within $LANDO_ZSH_SITES_DIRECTORY
  23. return 1
  24. fi
  25. local curr_dir="$PWD"
  26. # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
  27. while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
  28. if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
  29. return 0
  30. fi
  31. curr_dir="${curr_dir:h}"
  32. done
  33. # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
  34. # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
  35. return 1
  36. }