Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when executing "bash" __git_ps1 is not found #290

Closed
kjeremy opened this issue Aug 19, 2015 · 3 comments · Fixed by git-for-windows/build-extra#72
Closed

when executing "bash" __git_ps1 is not found #290

kjeremy opened this issue Aug 19, 2015 · 3 comments · Fixed by git-for-windows/build-extra#72

Comments

@kjeremy
Copy link

kjeremy commented Aug 19, 2015

If I'm running Git Bash and from the shell type in "bash" to launch a subshell I see bash: __git_ps1: command not found and I lose the branch information that was in the original bash prompt.

@dscho
Copy link
Member

dscho commented Aug 19, 2015

This is a known issue: when launching bash without --login, the profile is not executed, and since the functions required for the prompt to work are not inherited by subshells, you see this error message.

Quick fix: always start bash --login.

Longer fix: figure out which file is sourced by bash when starting a subshell (maybe /etc/bash.bashrc?) and put special code there to re-initialize the prompt when an interactive console is detected.

@kjeremy you up for the task?

@dscho
Copy link
Member

dscho commented Aug 19, 2015

@kjeremy it would be nice to see a contributions from your side.

The proper fix for this would actually be to move the prompt from the profile to the bashrc. We can do this in git-extra but we must take pains to move the git-prompt.sh outside /etc/profile.d/ lest it be sourced as part of /etc/profile (and hence double-sourced). Then we need to edit /etc/bash.bashrc as part of git-extra.install to add the line (if it is not there yet):

test ! -t 0 || . /etc/git-prompt.sh

And then all this needs to be tested thoroughly. Ball's in your court now 😃

@nalla
Copy link

nalla commented Aug 20, 2015

No need to move git-prompt.sh. Just adding shopt -q login_shell || . /etc/profile.d/git-prompt.sh to the bash.bashrc sould be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants