Note that there are some explanatory texts on larger screens.

plurals
  1. PO(Mac) -bash: __git_ps1: command not found
    text
    copied!<p>I'm trying to change my command promt in terminal. I keep getting the error:</p> <p><code>-bash: __git_ps1: command not found</code></p> <p>I've tried it just by typing it into the terminal as is: <code>__git_ps1</code>. I've also tried it out in the <code>.bash_profile</code></p> <pre><code>if [ -f ~/.git-completion.bash ]; then source ~/.git-completion.bash export PS1='[\W]$(__git_ps1 "(%s)"): ' fi </code></pre> <p>As you might be able to see/tell, yes, I do have the auto-completion installed and it does work great!</p> <p>I came across this question: " <a href="https://stackoverflow.com/questions/10435117/ps1-env-variable-does-not-work-on-mac">PS1 env variable does not work on mac</a> " which gives the code</p> <p><code>alias __git_ps1="git branch 2&gt;/dev/null | grep '*' | sed 's/* \(.*\)/(\1)/'"</code></p> <p>So I add it to my <code>.bash_profile</code> hoping that it will change something. Well, it did. It just changed the error output.</p> <p>Here's the <code>.bash_profile</code> with the addition:</p> <pre><code>alias __git_ps1="git branch 2&gt;/dev/null | grep '*' | sed 's/* \(.*\)/(\1)/'" if [ -f ~/.git-completion.bash ]; then source ~/.git-completion.bash export PS1='[\W]$(__git_ps1 "(%s)"): ' fi </code></pre> <p>And now here's the changed error output:</p> <p><code>sed: (%s): No such file or directory</code></p> <p><strong><em>Note:</em></strong> I've also moved the alias below the source with no difference. I have <em>git version 1.7.12.1</em></p> <p>This should be a simple change. Can someone please help me?</p> <p><strong>Edit 10/13/12</strong></p> <p>No, I definitely do not want to define __git_ps1 myself but was just trying to see if it would be recognized by doing so. Yes, I have the <code>.git-completion.bash</code> file installed. Here's how I got auto completion on my machine.</p> <pre><code>cd ~ curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash mv ~/git.completion.bash ~/.git-completion.bash </code></pre> <p>A <code>ls -la</code> then lists the <code>.git-completion.bash</code> file.</p> <p><strong>Edit 10/13/12 - Solved by <em>Mark Longair</em> (below)</strong></p> <p>The following code worked for me in the <code>.bash_profile</code> while others did not...</p> <pre><code>if [ -f ~/.git-prompt.sh ]; then source ~/.git-prompt.sh export PS1='Geoff[\W]$(__git_ps1 "(%s)"): ' fi </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload