Created
August 21, 2012 05:09
-
-
Save alecthegeek/3411900 to your computer and use it in GitHub Desktop.
Fix for Git Prompt in Homebrew
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Upgraded git using Homebrew and now your __git_ps1() fails. Try something like this | |
# NB Still very fragile as had embedded version no | |
# enable git programmable completion features | |
if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then | |
. /usr/local/etc/bash_completion.d/git-completion.bash | |
fi | |
# enable git prompt | |
if [ -f /usr/local/Cellar/git/1.7.12/share/git-core/contrib/completion/git-prompt.sh ]; then | |
. /usr/local/Cellar/git/1.7.12/share/git-core/contrib/completion/git-prompt.sh | |
PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w \$(__git_ps1 \" (%s)\")$" | |
fi | |
Just in case someone stumbles upon this in 2019+
Working code would now be:
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
if [ -f `brew --prefix`/etc/bash_completion.d/git-prompt.sh ]; then
. `brew --prefix`/etc/bash_completion.d/git-prompt.sh
PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w \$(__git_ps1 \" (%s)\")$"
fi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could replace
/usr/local
withbrew --prefix
and/usr/local/Cellar/git/1.7.12
withbrew --prefix git
to make it more robust: