-bash: __git_ps1: command not found
Solution 1
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.
Solution 2
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() { : ; }
Ben
Updated on September 18, 2022Comments
-
Ben almost 2 years
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
-
Ben almost 11 yearsI'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?
-
jjlin almost 11 yearsI didn't see your
~/.bash_prompt
file in your paste. But you can run a command likefind ~ -type f | xargs fgrep PS1=
to find wherePS1
is getting set. If it's not in~
, then try replacing that with/etc
. -
Bob McBobson over 4 yearsNote: this might be a noob nitpicking, but I found the problematic line in my .bash_profile file, not .bash_prompt.
-
jjlin over 4 years@BobMcBobson Yes,
~/.bash_prompt
was specific to the OP's question/environment. Most people will probably have it in~/.bash_profile
or~/.bashrc
.