jimeh / git-aware-prompt

Display current Git branch name in your terminal prompt when in a Git working directory.
Creative Commons Zero v1.0 Universal
2.15k stars 340 forks source link

Not working on my Ubuntu 14.04 LTS #34

Closed nielsonsantana closed 8 years ago

nielsonsantana commented 8 years ago

I put this settings on my .bashrc

export GITAWAREPROMPT=~/bin/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1='$(basename "$PWD")\[\033[00m\]: \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$:'

I guess that the problem was main.sh, colors.sh, prompt.sh don't have permission, then I executed:

chmod +x main.sh colors.sh prompt.sh

Even, after it, don't work. Result in my bash:

git-aware-prompt: $git_branch$git_dirty$:

jimeh commented 8 years ago

The problem is your PS1 line is wrapped in single quotes, which means all the $ variables are note interpolated.

Change it to:

export PS1="$(basename "$PWD")\[\033[00m\]: \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$:"

The double quotes around $PWD can be left alone like that cause it's enclosed in $(...), I'm assuming that's why you've got single quotes instead of double quotes. It's weird, confusing, but works... lol

nielsonsantana commented 8 years ago

I put a single quote because on my PSI command , there a double quote "$PWD". When I execute $PROMP_COMMAND, I get this error:

find_git_branch;: command not found

However, when I try: echo $git_branch I get:

(master)
nielsonsantana commented 8 years ago

Thanks @jimeh. Worked with double quote.

export PS1="$(basename $PWD)\[\033[00m\]~\[$txtcyn\]\${git_branch}\[$txtred\]\$git_dirty\[$txtrst\]\$: "

jimeh commented 8 years ago

No worries. Happy to help :)