mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-16 02:40:08 +00:00
refactor(lando): add LANDO_ZSH_WRAPPED_COMMANDS
setting and refactor
This commit is contained in:
parent
a8dee63ffe
commit
d082d87580
2 changed files with 32 additions and 11 deletions
|
@ -8,7 +8,7 @@ To use it, add `lando` to the plugins array in your zshrc file:
|
||||||
plugins=(... lando)
|
plugins=(... lando)
|
||||||
```
|
```
|
||||||
|
|
||||||
## ALIASES:
|
## Wrapped Commands
|
||||||
|
|
||||||
| Alias | Description |
|
| Alias | Description |
|
||||||
|:----------:|:----------------:|
|
|:----------:|:----------------:|
|
||||||
|
@ -21,16 +21,34 @@ plugins=(... lando)
|
||||||
| `wp` | `lando wp` |
|
| `wp` | `lando wp` |
|
||||||
| `yarn` | `lando yarn` |
|
| `yarn` | `lando yarn` |
|
||||||
|
|
||||||
|
More or different commands can be wrapped by setting the `LANDO_ZSH_WRAPPED_COMMANDS` setting, see [Settings](#settings) below.
|
||||||
|
|
||||||
## How It Works:
|
## 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:
|
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 `.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.
|
- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
|
||||||
|
- If the command is not a part of the commands available in the lando environment, it will run the command without `lando`.
|
||||||
|
|
||||||
## Settings:
|
## Settings:
|
||||||
|
|
||||||
- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
|
> NOTE: these settings must be set *before* the plugin is loaded, and any changes require a restart of the shell to be applied.
|
||||||
- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
|
|
||||||
|
- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory:
|
||||||
|
```sh
|
||||||
|
LANDO_ZSH_SITES_DIRECTORY="$HOME/Code"
|
||||||
|
```
|
||||||
|
|
||||||
|
- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando:
|
||||||
|
```sh
|
||||||
|
LANDO_ZSH_CONFIG_FILE=".lando.dev.yml"
|
||||||
|
```
|
||||||
|
|
||||||
|
- `LANDO_ZSH_WRAPPED_COMMANDS`: The list of commands to wrap, as a string of commands separated by whitespace:
|
||||||
|
```sh
|
||||||
|
LANDO_ZSH_WRAPPED_COMMANDS="mysql php composer test artisan"
|
||||||
|
```
|
||||||
|
|
||||||
## Author:
|
## Author:
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
# Settings
|
# Settings
|
||||||
: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
|
: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
|
||||||
: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
|
: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
|
||||||
|
: ${LANDO_ZSH_WRAPPED_COMMANDS:="
|
||||||
|
artisan
|
||||||
|
composer
|
||||||
|
drush
|
||||||
|
gulp
|
||||||
|
npm
|
||||||
|
php
|
||||||
|
wp
|
||||||
|
yarn
|
||||||
|
"}
|
||||||
|
|
||||||
# Enable multiple commands with lando.
|
# Enable multiple commands with lando.
|
||||||
function artisan \
|
function ${=LANDO_ZSH_WRAPPED_COMMANDS} {
|
||||||
composer \
|
|
||||||
drush \
|
|
||||||
gulp \
|
|
||||||
npm \
|
|
||||||
php \
|
|
||||||
wp \
|
|
||||||
yarn {
|
|
||||||
# If the lando task is available in `lando --help`, then it means:
|
# If the lando task is available in `lando --help`, then it means:
|
||||||
#
|
#
|
||||||
# 1. `lando` is in a project with a `.lando.yml` file.
|
# 1. `lando` is in a project with a `.lando.yml` file.
|
||||||
|
|
Loading…
Reference in a new issue