I installed drush and as part of the installation it makes some changes to the command prompt.

# Optional. Enrich the bash startup file with completion and aliases.
drush init

Whenever I execute an command at the prompt I get the message:

bash: __drush_ps1: command not found

The env command displays PROMPT_COMMAND as

PROMPT_COMMAND=__git_ps1 "\u@\h \w" "$(__drush_ps1 "[%s]") \\\$ "

I think somewhere at the global level the PROMPT_COMMAND variable is set to that value but I can't locate it in any of the global environment variables and profile scripts.

Because drush was installed as root commands executed as root don't produce that error message. root has a .drush directory with some drush scripts.

2 Answers 2


The function that changes the .bash_profile or .bashrc file is drush_init_core_init(). The shell script that effectively sets the prompt is $home/.drush/drush.prompt.sh, where $home is the value returned from drush_server_home(). If the file doesn't exist, drush_init_core_init() creates it from the content of DRUSH_BASE_PATH . "/examples/example.prompt.sh", which contains the following line. (See example.prompt.sh.)

export PROMPT_COMMAND='__git_ps1 "\u@\h \w" "$(__drush_ps1 "[%s]") \\\$ "'

There is also the following line, which sets PS1 and that is is commented out by default. (See the comment before it.)

  # PROMPT_COMMAND is used in the example above rather than PS1 because neither
  # Git nor Drush color hints are compatible with PS1. If you don't want color
  # hints, however, and prefer to use PS1, you can still do so by commenting out
  # the PROMPT_COMMAND line above and uncommenting the PS1 line below:
  # export PS1='\u@\h \w$(__git_ps1 " (%s)")$(__drush_ps1 "[%s]")\$ '

As for the error message you see, __drush_ps1() is a bash function used to change the prompt, defined in drush.complete.sh. bash completion/prompt broken explains exactly when and why you get that error. TLDR; in some circumstances, the shell script is not sourced, and the Bash function results not defined.
For what I understand it, the error has been has been fixed in recent versions, though, so you should just need to update Drush to fix the error.

  • The problem is I don't know which file sets the PROMPT_COMMAND in both the user's bash configuration filEs and in /etc/. I'd prefer to change it in there. None of the files in /etc/bash_completion.d contain any command to set PROMPT_COMMAND.
    – vfclists
    Apr 19, 2016 at 14:36
  • I will add that information in the answer.
    – apaderno
    Apr 19, 2016 at 16:09

Kind of simpler work-around to remove that error message - edit:



nano ~/.drusysconfig/bash_prompt

and remove row:

PS1="\[${BOLD}${MAGENTA}\]\u\[$WHITE\]@\[$ORANGE\]\h\[$WHITE\]:\[$GREEN\]\w \[$PURPLE\]\$(__git_ps1 '(%s)')\[$ORANGE\]\[$WHITE\]\n\$ \[$RESET\]"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.