2

I recently uninstalled Homebrew and Cellar (web dev applications), and this error now appears after every Terminal command (although I can't confirm that these are the culprits!):

-bash: __git_ps1: command not found.

I reinstalled both applications yet the error message still happens! I'm attaching my Bash file just incase it's related - PasteBin

2 Answers 2

4

You probably want to look in your ~/.bash_prompt file, or whatever file is setting PS1 (the shell prompt format) for you. Your PS1 variable is referencing the Git prompt function, which I assume got uninstalled or something. You'll want to remove the $(__git_ps1 " (%s)") part from your PS1 value.

4
  • I've checked my ~/.bash_prompt file (see attached in original) and I can't find anything referencing that. Is there a quicker way of, say for instance, searching for this PS1 value?
    – Ben
    Sep 18, 2013 at 16:57
  • I didn't see your ~/.bash_prompt file in your paste. But you can run a command like find ~ -type f | xargs fgrep PS1= to find where PS1 is getting set. If it's not in ~, then try replacing that with /etc.
    – jjlin
    Sep 18, 2013 at 17:15
  • Note: this might be a noob nitpicking, but I found the problematic line in my .bash_profile file, not .bash_prompt. Nov 10, 2019 at 0:53
  • @BobMcBobson Yes, ~/.bash_prompt was specific to the OP's question/environment. Most people will probably have it in ~/.bash_profile or ~/.bashrc.
    – jjlin
    Nov 10, 2019 at 1:25
4

Assuming that you want (or eventually might want) to use git, then the git status in the prompt is quite useful. If using the git-osx-installer, source git-completion.bash (e.g. found in /usr/local/git/contrib/completion/) from your .bash_profile (or .bashrc or .bash_prompt etc), in order to to define the function __git_ps1.

Alternatively, you may prefer to install git & the corresponding git bash completion via macports (sudo port install git-core +bash_completion) or via homebrew, following the respective install steps for each. (See also: How to get git-completion.bash to work on Mac OS X?)

The main gotcha for bash completion is that it requires a newer version of bash (>= 4.1) than comes w/ OSX by default, so you will want to install/use the newer bash that comes with macports/homebrew/etc. (echo $BASH_VERSION).

Alternatively, if you don't want to deal with hacking your PS1 prompt or installing git & git completion, you may simply define the function yourself to be a no-op (e.g., in your .bashrc or .bash_profile etc):

__git_ps1() { : ; }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .