1 # -*- mode: shell-script; mode: flyspell-prog; ispell-local-dictionary: "american" -*-
5 # Use `drush init` to copy this to ~/.drush/drush.prompt.sh, and source it in ~/.bashrc
9 # Displays Git repository and Drush alias status in your prompt.
10 if [ -n "$(type -t __git_ps1)" ] && [ "$(type -t __git_ps1)" = function ] && [ "$(type -t __drush_ps1)" ] && [ "$(type -t __drush_ps1)" = function ]; then
12 # This line enables color hints in your Drush prompt. Modify the below
13 # __drush_ps1_colorize_alias() to customize your color theme.
14 DRUSH_PS1_SHOWCOLORHINTS=true
16 # Git offers various prompt customization options as well as seen in
17 # https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh.
18 # Adjust the following lines to enable the corresponding features:
20 GIT_PS1_SHOWDIRTYSTATE=true
21 GIT_PS1_SHOWUPSTREAM=auto
22 # GIT_PS1_SHOWSTASHSTATE=true
23 # GIT_PS1_SHOWUNTRACKEDFILES=true
24 GIT_PS1_SHOWCOLORHINTS=true
26 # The following line sets your bash prompt according to this example:
28 # username@hostname ~/working-directory (git-branch)[@drush-alias] $
30 # See http://ss64.com/bash/syntax-prompt.html for customization options.
31 export PROMPT_COMMAND='__git_ps1 "\u@\h \w" "$(__drush_ps1 "[%s]") \\\$ "'
33 # PROMPT_COMMAND is used in the example above rather than PS1 because neither
34 # Git nor Drush color hints are compatible with PS1. If you don't want color
35 # hints, however, and prefer to use PS1, you can still do so by commenting out
36 # the PROMPT_COMMAND line above and uncommenting the PS1 line below:
38 # export PS1='\u@\h \w$(__git_ps1 " (%s)")$(__drush_ps1 "[%s]")\$ '
40 __drush_ps1_colorize_alias() {
41 if [[ -n ${ZSH_VERSION-} ]]; then
42 local COLOR_BLUE='%F{blue}'
43 local COLOR_CYAN='%F{cyan}'
44 local COLOR_GREEN='%F{green}'
45 local COLOR_MAGENTA='%F{magenta}'
46 local COLOR_RED='%F{red}'
47 local COLOR_WHITE='%F{white}'
48 local COLOR_YELLOW='%F{yellow}'
51 # Using \[ and \] around colors is necessary to prevent issues with
52 # command line editing/browsing/completion.
53 local COLOR_BLUE='\[\e[94m\]'
54 local COLOR_CYAN='\[\e[36m\]'
55 local COLOR_GREEN='\[\e[32m\]'
56 local COLOR_MAGENTA='\[\e[35m\]'
57 local COLOR_RED='\[\e[91m\]'
58 local COLOR_WHITE='\[\e[37m\]'
59 local COLOR_YELLOW='\[\e[93m\]'
60 local COLOR_NONE='\[\e[0m\]'
63 # Customize your color theme below.
64 case "$__DRUPAL_SITE" in
65 *.live|*.prod) local ENV_COLOR="$COLOR_RED" ;;
66 *.stage|*.test) local ENV_COLOR="$COLOR_YELLOW" ;;
67 *.local) local ENV_COLOR="$COLOR_GREEN" ;;
68 *) local ENV_COLOR="$COLOR_BLUE" ;;
71 __DRUPAL_SITE="${ENV_COLOR}${__DRUPAL_SITE}${COLOR_NONE}"