Unverified Commit 4cd5f7f9 authored by Joshua Bedford's avatar Joshua Bedford Committed by GitHub
Browse files

Add lando plugin (#8748)


Co-authored-by: default avatarJoshua Bedford <joshua.bedford@hurstreview.com>
Co-authored-by: default avatarMarc Cornellà <marc.cornella@live.com>
parent a5e706d7
MIT License
Copyright (c) 2019 Joshua Bedford
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
# Lando ZSH (lando-zsh)
This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories.
To use it, add `lando` to the plugins array in your zshrc file:
```zsh
plugins=(... lando)
```
## ALIASES:
| Alias | Description |
|:----------:|:----------------:|
| `artisan` | `lando artisan` |
| `composer` | `lando composer` |
| `drush` | `lando drush` |
| `gulp` | `lando gulp` |
| `npm` | `lando npm` |
| `wp` | `lando wp` |
| `yarn` | `lando yarn` |
## How It Works:
This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
## Settings:
- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
## Author:
- Author: Joshua Bedford
- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh)
# 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment