style(drush): fix code and README style

This commit is contained in:
Marc Cornellà 2021-12-28 17:49:41 +01:00
parent c4be9294f2
commit 01230fa6e2
No known key found for this signature in database
GPG Key ID: 0314585E776A9C1B
2 changed files with 86 additions and 112 deletions

View File

@ -1,83 +1,60 @@
# Drush # Drush
## Description This plugin adds aliases and functions for [Drush](https://www.drush.org), a command-line shell
This plugin offers aliases and functions to make the work with drush easier and more productive. and Unix scripting interface for Drupal. It also adds completion for the `drush` command.
To enable it, add the `drush` to your `plugins` array in `~/.zshrc`: To enable it, add `drush` to the plugins array in zshrc file:
``` ```zsh
plugins=(... drush) plugins=(... drush)
``` ```
## Aliases ## Aliases
| Alias | Description | Command |
|-------|-----------------------------------------------------------------------|-----------------------------| | Alias | Command | Description |
| dr | Display drush help | drush | | ------- | ------------------------------------------------------------ | --------------------------------------------------------------------- |
| drca | Clear all drupal caches. | drush cc all | | `dr` | `drush` | Display drush help |
| drcb | Clear block cache. | drush cc block | | `drca` | `drush cc all` | _(Deprecated in Drush 8)_ Clear all drupal caches. |
| drcg | Clear registry cache. | drush cc registry | | `drcb` | `drush cc block` | _(Deprecated in Drush 8)_ Clear block cache. |
| drcj | Clear css-js cache. | drush cc css-js | | `drcg` | `drush cc registry` | _(Deprecated in Drush 8)_ Clear registry cache. |
| drcm | Clear menu cache. | drush cc menu | | `drcj` | `drush cc css-js` | Clear css-js cache. |
| drcml | Clear module-list cache. | drush cc module-list | | `drcm` | `drush cc menu` | Clear menu cache. |
| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron | | `drcml` | `drush cc module-list` | Clear module-list cache. |
| drct | Clear theme-registry cache. | drush cc theme-registry | | `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site. |
| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views | | `drct` | `drush cc theme-registry` | Clear theme-registry cache. |
| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql| | `drcv` | `drush cc views` | Clear views cache. (Make sure that the views module is enabled) |
| drf | Display features status | drush features | | `drdmp` | `drush drush sql-dump --ordered-dump --result-file=dump.sql` | Backup database in a new dump.sql file |
| drfr | Revert a feature module on your site. | drush features-revert -y | | `drf` | `drush features` | Display features status |
| drfu | Update a feature module on your site. | drush features-update -y | | `drfr` | `drush features-revert -y` | Revert a feature module on your site. |
| drfra | Revert all enabled feature module on your site. | drush features-revert-all | | `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site. |
| drif | Flush all derived images. | drush image-flush --all | | `drfu` | `drush features-update -y` | Update a feature module on your site. |
| drpm | Show a list of available modules. | drush pm-list --type=module | | `drif` | `drush image-flush --all` | Flush all derived images. |
| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status | | `drpm` | `drush pm-list --type=module` | Show a list of available modules. |
| drup | Apply any database updates required (as with running update.php). | drush updatedb | | `drst` | `drush core-status` | Provides a birds-eye view of the current Drupal installation, if any. |
| drups | List any pending database updates. | drush updatedb-status | | `drup` | `drush updatedb` | Apply any database updates required (as with running update.php). |
| drv | Show drush version. | drush version | | `drups` | `drush updatedb-status` | List any pending database updates. |
| drvd | Delete a variable. | drush variable-del | | `drv` | `drush version` | Show drush version. |
| drvg | Get a list of some or all site variables and values. | drush variable-get | | `drvd` | `drush variable-del` | Delete a variable. |
| drvs | Set a variable. | drush variable-set | | `drvg` | `drush variable-get` | Get a list of some or all site variables and values. |
| `drvs` | `drush variable-set` | Set a variable. |
## Functions ## Functions
### dren - `dren`: download and enable one or more extensions (modules or themes). Must be
Download and enable one or more extensions (modules or themes). invoked with one or more parameters, e.g.: `dren devel` or `dren devel module_filter views`.
Must be invoked with one or more parameters. e.g.:
`dren devel` or `dren devel module_filter views`
### drf - `drf`: edit drushrc, site alias, and Drupal settings.php files.
Edit drushrc, site alias, and Drupal settings.php files. Can be invoked with one or without parameters, e.g.: `drf 1`.
Can be invoked with one or without parameters. e.g.:
`drf 1`
### dris - `dris`: disable one or more extensions (modules or themes). Must be invoked with
Disable one or more extensions (modules or themes) one or more parameters, e.g.: `dris devel` or `dris devel module_filter views`.
Must be invoked with one or more parameters. e.g.:
`dris devel` or `dris devel module_filter views`
### drpu - `drpu`: uninstall one or more modules. Must be invoked with one or more
Uninstall one or more modules. parameters, e.g.: `drpu devel` or `drpu devel module_filter views`.
Must be invoked with one or more parameters. e.g.:
`drpu devel` or `drpu devel module_filter views`
### drnew - `drnew`: creates a brand new drupal website. Note: as soon as the installation
Creates a brand new drupal website. is complete, `drush` will print a username and a random password into the terminal:
Note: As soon as the installation is complete, drush will print a username and a random password into the terminal:
```
Installation complete. User name: admin User password: cf7t8yqNEm
```
## Additional features ```text
Installation complete. User name: admin User password: cf7t8yqNEm
### Autocomplete ```
The [completion script for drush](https://github.com/drush-ops/drush/blob/8.0.1/drush.complete.sh) comes enabled with this plugin.
So, it is possible to type a command:
```
drush sql
```
And as soon as the tab key is pressed, the script will display the available commands:
```
drush sql
sqlc sql-conf sql-create sql-dump sql-query sql-sanitize
sql-cli sql-connect sql-drop sqlq sqlsan sql-sync
```

View File

@ -1,19 +1,18 @@
# Drush support. # Functions
function dren() { function dren() {
drush en $@ -y drush en "$@" -y
} }
function dris() { function dris() {
drush pm-disable $@ -y drush pm-disable "$@" -y
} }
function drpu() { function drpu() {
drush pm-uninstall $@ -y drush pm-uninstall "$@" -y
} }
function drf() { function drf() {
if [[ $1 == "" ]] then if [[ -z "$1" ]] then
drush core-config drush core-config
else else
drush core-config --choice=$1 drush core-config --choice=$1
@ -21,58 +20,56 @@ function drf() {
} }
function drfi() { function drfi() {
if [[ $1 == "fields" ]]; then case "$1" in
drush field-info fields fields) drush field-info fields ;;
elif [[ $1 == "types" ]]; then types) drush field-info types ;;
drush field-info types *) drush field-info ;;
else esac
drush field-info
fi
} }
function drnew() { function drnew() {
(
cd
echo "Website's name: "
read WEBSITE_NAME
cd ~ HOST=http://$(hostname -i)/
echo "Website's name: "
read WEBSITE_NAME
HOST=http://$(hostname -i)/ if [[ $WEBSITE_NAME == "" ]] then
MINUTES=$(date +%M:%S)
WEBSITE_NAME="Drupal-$MINUTES"
echo "Your website will be named: $WEBSITE_NAME"
fi
if [[ $WEBSITE_NAME == "" ]] then drush dl drupal --drupal-project-rename=$WEBSITE_NAME
MINUTES=$(date +%M:%S)
WEBSITE_NAME="Drupal-$MINUTES"
echo "Your website will be named: $WEBSITE_NAME"
fi
drush dl drupal --drupal-project-rename=$WEBSITE_NAME echo "Type your localhost directory: (Leave empty for /var/www/html/)"
read DIRECTORY
echo "Type your localhost directory: (Leave empty for /var/www/html/)" if [[ $DIRECTORY == "" ]] then
read DIRECTORY DIRECTORY="/var/www/html/"
fi
if [[ $DIRECTORY == "" ]] then echo "Moving to $DIRECTORY$WEBSITE_NAME"
DIRECTORY="/var/www/html/" sudo mv $WEBSITE_NAME $DIRECTORY
fi cd $DIRECTORY$WEBSITE_NAME
echo "Moving to $DIRECTORY$WEBSITE_NAME" echo "Database's user: "
sudo mv $WEBSITE_NAME $DIRECTORY read DATABASE_USR
cd $DIRECTORY$WEBSITE_NAME echo "Database's password: "
read -s DATABASE_PWD
echo "Database's name for your project: "
read DATABASE
echo "Database's user: " DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE"
read DATABASE_USR drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME
echo "Database's password: "
read -s DATABASE_PWD
echo "Database's name for your project: "
read DATABASE
DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE"
drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME
open_command $HOST$WEBSITE_NAME
echo "Done"
open_command $HOST$WEBSITE_NAME
echo "Done"
)
} }
# Aliases, sorted alphabetically. # Aliases
alias dr="drush" alias dr="drush"
alias drca="drush cc all" # Deprecated for Drush 8 alias drca="drush cc all" # Deprecated for Drush 8
alias drcb="drush cc block" # Deprecated for Drush 8 alias drcb="drush cc block" # Deprecated for Drush 8
@ -86,8 +83,8 @@ alias drcv="drush cc views"
alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql" alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql"
alias drf="drush features" alias drf="drush features"
alias drfr="drush features-revert -y" alias drfr="drush features-revert -y"
alias drfu="drush features-update -y"
alias drfra="drush features-revert-all" alias drfra="drush features-revert-all"
alias drfu="drush features-update -y"
alias drif="drush image-flush --all" alias drif="drush image-flush --all"
alias drpm="drush pm-list --type=module" alias drpm="drush pm-list --type=module"
alias drst="drush core-status" alias drst="drush core-status"