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