mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 21:39:48 +01:00
Add drush plugin (#4490)
This commit is contained in:
parent
a43cef3404
commit
f1799de0c9
3 changed files with 237 additions and 0 deletions
83
plugins/drush/README.md
Normal file
83
plugins/drush/README.md
Normal file
|
@ -0,0 +1,83 @@
|
|||
# Drush
|
||||
|
||||
## Description
|
||||
This plugin offers aliases and functions to make the work with drush easier and more productive.
|
||||
|
||||
To enable it, add the `drush` to your `plugins` array in `~/.zshrc`:
|
||||
|
||||
```
|
||||
plugins=(... drush)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
| Alias | Description | Command |
|
||||
|-------|-----------------------------------------------------------------------|-----------------------------|
|
||||
| dr | Display drush help | drush |
|
||||
| drca | Clear all drupal caches. | drush cc all |
|
||||
| drcb | Clear block cache. | drush cc block |
|
||||
| drcg | Clear registry cache. | drush cc registry |
|
||||
| drcj | Clear css-js cache. | drush cc css-js |
|
||||
| drcm | Clear menu cache. | drush cc menu |
|
||||
| drcml | Clear module-list cache. | drush cc module-list |
|
||||
| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron |
|
||||
| drct | Clear theme-registry cache. | drush cc theme-registry |
|
||||
| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views |
|
||||
| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql|
|
||||
| drf | Display features status | drush features |
|
||||
| drfr | Revert a feature module on your site. | drush features-revert -y |
|
||||
| drfu | Update a feature module on your site. | drush features-update -y |
|
||||
| drfra | Revert all enabled feature module on your site. | drush features-revert-all |
|
||||
| drif | Flush all derived images. | drush image-flush --all |
|
||||
| drpm | Show a list of available modules. | drush pm-list --type=module |
|
||||
| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status |
|
||||
| drup | Apply any database updates required (as with running update.php). | drush updatedb |
|
||||
| drups | List any pending database updates. | drush updatedb-status |
|
||||
| drv | Show drush version. | drush version |
|
||||
| drvd | Delete a variable. | drush variable-del |
|
||||
| drvg | Get a list of some or all site variables and values. | drush variable-get |
|
||||
| drvs | Set a variable. | drush variable-set |
|
||||
|
||||
## Functions
|
||||
|
||||
### dren
|
||||
Download and enable one or more extensions (modules or themes).
|
||||
Must be invoked with one or more parameters. e.g.:
|
||||
`dren devel` or `dren devel module_filter views`
|
||||
|
||||
### drf
|
||||
Edit drushrc, site alias, and Drupal settings.php files.
|
||||
Can be invoked with one or without parameters. e.g.:
|
||||
`drf 1`
|
||||
|
||||
### dris
|
||||
Disable one or more extensions (modules or themes)
|
||||
Must be invoked with one or more parameters. e.g.:
|
||||
`dris devel` or `dris devel module_filter views`
|
||||
|
||||
### drpu
|
||||
Uninstall one or more modules.
|
||||
Must be invoked with one or more parameters. e.g.:
|
||||
`drpu devel` or `drpu devel module_filter views`
|
||||
|
||||
### drnew
|
||||
Creates a brand new drupal website.
|
||||
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
|
||||
|
||||
### 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
|
||||
```
|
50
plugins/drush/drush.complete.sh
Normal file
50
plugins/drush/drush.complete.sh
Normal file
|
@ -0,0 +1,50 @@
|
|||
# BASH completion script for Drush.
|
||||
#
|
||||
# Place this in your /etc/bash_completion.d/ directory or source it from your
|
||||
# ~/.bash_completion or ~/.bash_profile files. Alternatively, source
|
||||
# examples/example.bashrc instead, as it will automatically find and source
|
||||
# this file.
|
||||
#
|
||||
# If you're using ZSH instead of BASH, add the following to your ~/.zshrc file
|
||||
# and source it.
|
||||
#
|
||||
# autoload bashcompinit
|
||||
# bashcompinit
|
||||
# source /path/to/your/drush.complete.sh
|
||||
|
||||
# Ensure drush is available.
|
||||
which drush > /dev/null || alias drush &> /dev/null || return
|
||||
|
||||
__drush_ps1() {
|
||||
f="${TMPDIR:-/tmp/}/drush-env-${USER}/drush-drupal-site-$$"
|
||||
if [ -f $f ]
|
||||
then
|
||||
__DRUPAL_SITE=$(cat "$f")
|
||||
else
|
||||
__DRUPAL_SITE="$DRUPAL_SITE"
|
||||
fi
|
||||
|
||||
# Set DRUSH_PS1_SHOWCOLORHINTS to a non-empty value and define a
|
||||
# __drush_ps1_colorize_alias() function for color hints in your Drush PS1
|
||||
# prompt. See example.prompt.sh for an example implementation.
|
||||
if [ -n "${__DRUPAL_SITE-}" ] && [ -n "${DRUSH_PS1_SHOWCOLORHINTS-}" ]; then
|
||||
__drush_ps1_colorize_alias
|
||||
fi
|
||||
|
||||
[[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE"
|
||||
}
|
||||
|
||||
# Completion function, uses the "drush complete" command to retrieve
|
||||
# completions for a specific command line COMP_WORDS.
|
||||
_drush_completion() {
|
||||
# Set IFS to newline (locally), since we only use newline separators, and
|
||||
# need to retain spaces (or not) after completions.
|
||||
local IFS=$'\n'
|
||||
# The '< /dev/null' is a work around for a bug in php libedit stdin handling.
|
||||
# Note that libedit in place of libreadline in some distributions. See:
|
||||
# https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214
|
||||
COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) )
|
||||
}
|
||||
|
||||
# Register our completion function. We include common short aliases for Drush.
|
||||
complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush7 drush8 drush.php
|
104
plugins/drush/drush.plugin.zsh
Normal file
104
plugins/drush/drush.plugin.zsh
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Drush support.
|
||||
|
||||
function dren() {
|
||||
drush en $@ -y
|
||||
}
|
||||
|
||||
function dris() {
|
||||
drush pm-disable $@ -y
|
||||
}
|
||||
|
||||
function drpu() {
|
||||
drush pm-uninstall $@ -y
|
||||
}
|
||||
|
||||
function drf() {
|
||||
if [[ $1 == "" ]] then
|
||||
drush core-config
|
||||
else
|
||||
drush core-config --choice=$1
|
||||
fi
|
||||
}
|
||||
|
||||
function drfi() {
|
||||
if [[ $1 == "fields" ]]; then
|
||||
drush field-info fields
|
||||
elif [[ $1 == "types" ]]; then
|
||||
drush field-info types
|
||||
else
|
||||
drush field-info
|
||||
fi
|
||||
}
|
||||
|
||||
function drnew() {
|
||||
|
||||
cd ~
|
||||
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
|
||||
|
||||
drush dl drupal --drupal-project-rename=$WEBSITE_NAME
|
||||
|
||||
echo "Type your localhost directory: (Leave empty for /var/www/html/)"
|
||||
read DIRECTORY
|
||||
|
||||
if [[ $DIRECTORY == "" ]] then
|
||||
DIRECTORY="/var/www/html/"
|
||||
fi
|
||||
|
||||
echo "Moving to $DIRECTORY$WEBSITE_NAME"
|
||||
sudo mv $WEBSITE_NAME $DIRECTORY
|
||||
cd $DIRECTORY$WEBSITE_NAME
|
||||
|
||||
echo "Database's user: "
|
||||
read DATABASE_USR
|
||||
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"
|
||||
|
||||
}
|
||||
|
||||
# Aliases, sorted alphabetically.
|
||||
alias dr="drush"
|
||||
alias drca="drush cc all" # Deprecated for Drush 8
|
||||
alias drcb="drush cc block" # Deprecated for Drush 8
|
||||
alias drcg="drush cc registry" # Deprecated for Drush 8
|
||||
alias drcj="drush cc css-js"
|
||||
alias drcm="drush cc menu"
|
||||
alias drcml="drush cc module-list"
|
||||
alias drcr="drush core-cron"
|
||||
alias drct="drush cc theme-registry"
|
||||
alias drcv="drush cc views"
|
||||
alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql"
|
||||
alias drf="drush features"
|
||||
alias drfr="drush features-revert -y"
|
||||
alias drfu="drush features-update -y"
|
||||
alias drfra="drush features-revert-all"
|
||||
alias drif="drush image-flush --all"
|
||||
alias drpm="drush pm-list --type=module"
|
||||
alias drst="drush core-status"
|
||||
alias drup="drush updatedb"
|
||||
alias drups="drush updatedb-status"
|
||||
alias drv="drush version"
|
||||
alias drvd="drush variable-del"
|
||||
alias drvg="drush variable-get"
|
||||
alias drvs="drush variable-set"
|
||||
|
||||
# Enable drush autocomplete support
|
||||
autoload bashcompinit
|
||||
bashcompinit
|
||||
source $(dirname $0)/drush.complete.sh
|
Loading…
Reference in a new issue