__git_ps1 not found but does exist











up vote
1
down vote

favorite












~/.bash_aliases where I set PS1, and is included in ~/.bashrc (the default settings)



# color PS1
PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "


But when I start a terminal I get error __git_ps1: command not found



But when I run the function manual $ __git_ps1 in a git folder it does echo the current branch.



Also when I manually run
$ PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "



the PS1 gets updated and __git_ps1 part does get added.



I did not install it myself. I only installed git.
sudo apt install -y git (git version 2.19.1)



__git_ps1 is defined in /usr/lib/git-core/git-sh-prompt (the file on github)



grep __git_ps1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null


Only the .bash_aliases file shows up.

A full grep of git-sh-promt only returns binary matches



sudo grep 'git-sh-prompt' -nr /


What is wrong here?



PS1 weirdness










share|improve this question




















  • 1




    Please don't post screenshots of text. Copy the text here and apply code formatting instead.
    – muru
    Nov 19 at 10:17










  • Also, if you used double quotes, $(__git_ps1) will be evaluated when PS1 is set, not when PS1 is used (i.e., when the prompt is printed).
    – muru
    Nov 19 at 10:18








  • 1




    The point is that we don't want screenshots when normal text will do. meta.askubuntu.com/q/8713/158442
    – muru
    Nov 19 at 10:37






  • 1




    Yes, @terdon, __git_ps1 does come with git, in particular with the file /usr/lib/git-core/git-sh-prompt. See my answer to the related question script to show git branch in bash no longer works on ubuntu 18.04.
    – PerlDuck
    Nov 19 at 11:59






  • 1




    You get that command not found only once, right? Not for every single prompt in the terminal? I'd guess the usage of __git_ps1 in the definition of $PS1 comes before the function gets defined (e.g. by sourcing git-sh-prompt or your file ~/.local/git-completion.bash (shown in an older version of your post)).
    – PerlDuck
    Nov 19 at 13:44















up vote
1
down vote

favorite












~/.bash_aliases where I set PS1, and is included in ~/.bashrc (the default settings)



# color PS1
PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "


But when I start a terminal I get error __git_ps1: command not found



But when I run the function manual $ __git_ps1 in a git folder it does echo the current branch.



Also when I manually run
$ PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "



the PS1 gets updated and __git_ps1 part does get added.



I did not install it myself. I only installed git.
sudo apt install -y git (git version 2.19.1)



__git_ps1 is defined in /usr/lib/git-core/git-sh-prompt (the file on github)



grep __git_ps1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null


Only the .bash_aliases file shows up.

A full grep of git-sh-promt only returns binary matches



sudo grep 'git-sh-prompt' -nr /


What is wrong here?



PS1 weirdness










share|improve this question




















  • 1




    Please don't post screenshots of text. Copy the text here and apply code formatting instead.
    – muru
    Nov 19 at 10:17










  • Also, if you used double quotes, $(__git_ps1) will be evaluated when PS1 is set, not when PS1 is used (i.e., when the prompt is printed).
    – muru
    Nov 19 at 10:18








  • 1




    The point is that we don't want screenshots when normal text will do. meta.askubuntu.com/q/8713/158442
    – muru
    Nov 19 at 10:37






  • 1




    Yes, @terdon, __git_ps1 does come with git, in particular with the file /usr/lib/git-core/git-sh-prompt. See my answer to the related question script to show git branch in bash no longer works on ubuntu 18.04.
    – PerlDuck
    Nov 19 at 11:59






  • 1




    You get that command not found only once, right? Not for every single prompt in the terminal? I'd guess the usage of __git_ps1 in the definition of $PS1 comes before the function gets defined (e.g. by sourcing git-sh-prompt or your file ~/.local/git-completion.bash (shown in an older version of your post)).
    – PerlDuck
    Nov 19 at 13:44













up vote
1
down vote

favorite









up vote
1
down vote

favorite











~/.bash_aliases where I set PS1, and is included in ~/.bashrc (the default settings)



# color PS1
PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "


But when I start a terminal I get error __git_ps1: command not found



But when I run the function manual $ __git_ps1 in a git folder it does echo the current branch.



Also when I manually run
$ PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "



the PS1 gets updated and __git_ps1 part does get added.



I did not install it myself. I only installed git.
sudo apt install -y git (git version 2.19.1)



__git_ps1 is defined in /usr/lib/git-core/git-sh-prompt (the file on github)



grep __git_ps1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null


Only the .bash_aliases file shows up.

A full grep of git-sh-promt only returns binary matches



sudo grep 'git-sh-prompt' -nr /


What is wrong here?



PS1 weirdness










share|improve this question















~/.bash_aliases where I set PS1, and is included in ~/.bashrc (the default settings)



# color PS1
PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "


But when I start a terminal I get error __git_ps1: command not found



But when I run the function manual $ __git_ps1 in a git folder it does echo the current branch.



Also when I manually run
$ PS1="[33[01;90m]D{%H:%M} [33[01;33m]Ubuntu[33[00m] [33[01;34m]w[33[01;35m]$(__git_ps1) [33[01;36m]$[33[00m] "



the PS1 gets updated and __git_ps1 part does get added.



I did not install it myself. I only installed git.
sudo apt install -y git (git version 2.19.1)



__git_ps1 is defined in /usr/lib/git-core/git-sh-prompt (the file on github)



grep __git_ps1 ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null


Only the .bash_aliases file shows up.

A full grep of git-sh-promt only returns binary matches



sudo grep 'git-sh-prompt' -nr /


What is wrong here?



PS1 weirdness







command-line bash prompt ps1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









wjandrea

7,81642258




7,81642258










asked Nov 19 at 10:15









janw

154214




154214








  • 1




    Please don't post screenshots of text. Copy the text here and apply code formatting instead.
    – muru
    Nov 19 at 10:17










  • Also, if you used double quotes, $(__git_ps1) will be evaluated when PS1 is set, not when PS1 is used (i.e., when the prompt is printed).
    – muru
    Nov 19 at 10:18








  • 1




    The point is that we don't want screenshots when normal text will do. meta.askubuntu.com/q/8713/158442
    – muru
    Nov 19 at 10:37






  • 1




    Yes, @terdon, __git_ps1 does come with git, in particular with the file /usr/lib/git-core/git-sh-prompt. See my answer to the related question script to show git branch in bash no longer works on ubuntu 18.04.
    – PerlDuck
    Nov 19 at 11:59






  • 1




    You get that command not found only once, right? Not for every single prompt in the terminal? I'd guess the usage of __git_ps1 in the definition of $PS1 comes before the function gets defined (e.g. by sourcing git-sh-prompt or your file ~/.local/git-completion.bash (shown in an older version of your post)).
    – PerlDuck
    Nov 19 at 13:44














  • 1




    Please don't post screenshots of text. Copy the text here and apply code formatting instead.
    – muru
    Nov 19 at 10:17










  • Also, if you used double quotes, $(__git_ps1) will be evaluated when PS1 is set, not when PS1 is used (i.e., when the prompt is printed).
    – muru
    Nov 19 at 10:18








  • 1




    The point is that we don't want screenshots when normal text will do. meta.askubuntu.com/q/8713/158442
    – muru
    Nov 19 at 10:37






  • 1




    Yes, @terdon, __git_ps1 does come with git, in particular with the file /usr/lib/git-core/git-sh-prompt. See my answer to the related question script to show git branch in bash no longer works on ubuntu 18.04.
    – PerlDuck
    Nov 19 at 11:59






  • 1




    You get that command not found only once, right? Not for every single prompt in the terminal? I'd guess the usage of __git_ps1 in the definition of $PS1 comes before the function gets defined (e.g. by sourcing git-sh-prompt or your file ~/.local/git-completion.bash (shown in an older version of your post)).
    – PerlDuck
    Nov 19 at 13:44








1




1




Please don't post screenshots of text. Copy the text here and apply code formatting instead.
– muru
Nov 19 at 10:17




Please don't post screenshots of text. Copy the text here and apply code formatting instead.
– muru
Nov 19 at 10:17












Also, if you used double quotes, $(__git_ps1) will be evaluated when PS1 is set, not when PS1 is used (i.e., when the prompt is printed).
– muru
Nov 19 at 10:18






Also, if you used double quotes, $(__git_ps1) will be evaluated when PS1 is set, not when PS1 is used (i.e., when the prompt is printed).
– muru
Nov 19 at 10:18






1




1




The point is that we don't want screenshots when normal text will do. meta.askubuntu.com/q/8713/158442
– muru
Nov 19 at 10:37




The point is that we don't want screenshots when normal text will do. meta.askubuntu.com/q/8713/158442
– muru
Nov 19 at 10:37




1




1




Yes, @terdon, __git_ps1 does come with git, in particular with the file /usr/lib/git-core/git-sh-prompt. See my answer to the related question script to show git branch in bash no longer works on ubuntu 18.04.
– PerlDuck
Nov 19 at 11:59




Yes, @terdon, __git_ps1 does come with git, in particular with the file /usr/lib/git-core/git-sh-prompt. See my answer to the related question script to show git branch in bash no longer works on ubuntu 18.04.
– PerlDuck
Nov 19 at 11:59




1




1




You get that command not found only once, right? Not for every single prompt in the terminal? I'd guess the usage of __git_ps1 in the definition of $PS1 comes before the function gets defined (e.g. by sourcing git-sh-prompt or your file ~/.local/git-completion.bash (shown in an older version of your post)).
– PerlDuck
Nov 19 at 13:44




You get that command not found only once, right? Not for every single prompt in the terminal? I'd guess the usage of __git_ps1 in the definition of $PS1 comes before the function gets defined (e.g. by sourcing git-sh-prompt or your file ~/.local/git-completion.bash (shown in an older version of your post)).
– PerlDuck
Nov 19 at 13:44










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Using a de-colorized version for clarity:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


The double quotes tell Bash to evaluate what is between the quotes, including $(__git_ps1), but /usr/lib/git-core/git-sh-prompt hasn't been sourced yet, hence the error.



Simply change it to use single quotes, which will prevent $(__git_ps1) from being evaluated until the PS1 is evaluated (i.e. when the interactive shell is ready for input and shows you the prompt).



PS1='D{%H:%M} Ubuntu w$(__git_ps1) $ '


Escaping the dollar sign also works, but it's harder to read:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


By the way, ~/.bash_aliases is intended for shell aliases, so it's a weird place to put your PS1. Personally I would put it in ~/.bashrc instead.






share|improve this answer























  • Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
    – janw
    Nov 19 at 21:43










  • Is there a way to check this source order?
    – janw
    Nov 19 at 21:46










  • Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
    – wjandrea
    Nov 19 at 21:53








  • 1




    @janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
    – wjandrea
    Nov 19 at 22:56












  • Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
    – janw
    Nov 20 at 8:31













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1094170%2fgit-ps1-not-found-but-does-exist%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










Using a de-colorized version for clarity:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


The double quotes tell Bash to evaluate what is between the quotes, including $(__git_ps1), but /usr/lib/git-core/git-sh-prompt hasn't been sourced yet, hence the error.



Simply change it to use single quotes, which will prevent $(__git_ps1) from being evaluated until the PS1 is evaluated (i.e. when the interactive shell is ready for input and shows you the prompt).



PS1='D{%H:%M} Ubuntu w$(__git_ps1) $ '


Escaping the dollar sign also works, but it's harder to read:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


By the way, ~/.bash_aliases is intended for shell aliases, so it's a weird place to put your PS1. Personally I would put it in ~/.bashrc instead.






share|improve this answer























  • Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
    – janw
    Nov 19 at 21:43










  • Is there a way to check this source order?
    – janw
    Nov 19 at 21:46










  • Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
    – wjandrea
    Nov 19 at 21:53








  • 1




    @janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
    – wjandrea
    Nov 19 at 22:56












  • Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
    – janw
    Nov 20 at 8:31

















up vote
2
down vote



accepted










Using a de-colorized version for clarity:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


The double quotes tell Bash to evaluate what is between the quotes, including $(__git_ps1), but /usr/lib/git-core/git-sh-prompt hasn't been sourced yet, hence the error.



Simply change it to use single quotes, which will prevent $(__git_ps1) from being evaluated until the PS1 is evaluated (i.e. when the interactive shell is ready for input and shows you the prompt).



PS1='D{%H:%M} Ubuntu w$(__git_ps1) $ '


Escaping the dollar sign also works, but it's harder to read:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


By the way, ~/.bash_aliases is intended for shell aliases, so it's a weird place to put your PS1. Personally I would put it in ~/.bashrc instead.






share|improve this answer























  • Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
    – janw
    Nov 19 at 21:43










  • Is there a way to check this source order?
    – janw
    Nov 19 at 21:46










  • Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
    – wjandrea
    Nov 19 at 21:53








  • 1




    @janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
    – wjandrea
    Nov 19 at 22:56












  • Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
    – janw
    Nov 20 at 8:31















up vote
2
down vote



accepted







up vote
2
down vote



accepted






Using a de-colorized version for clarity:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


The double quotes tell Bash to evaluate what is between the quotes, including $(__git_ps1), but /usr/lib/git-core/git-sh-prompt hasn't been sourced yet, hence the error.



Simply change it to use single quotes, which will prevent $(__git_ps1) from being evaluated until the PS1 is evaluated (i.e. when the interactive shell is ready for input and shows you the prompt).



PS1='D{%H:%M} Ubuntu w$(__git_ps1) $ '


Escaping the dollar sign also works, but it's harder to read:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


By the way, ~/.bash_aliases is intended for shell aliases, so it's a weird place to put your PS1. Personally I would put it in ~/.bashrc instead.






share|improve this answer














Using a de-colorized version for clarity:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


The double quotes tell Bash to evaluate what is between the quotes, including $(__git_ps1), but /usr/lib/git-core/git-sh-prompt hasn't been sourced yet, hence the error.



Simply change it to use single quotes, which will prevent $(__git_ps1) from being evaluated until the PS1 is evaluated (i.e. when the interactive shell is ready for input and shows you the prompt).



PS1='D{%H:%M} Ubuntu w$(__git_ps1) $ '


Escaping the dollar sign also works, but it's harder to read:



PS1="D{%H:%M} Ubuntu w$(__git_ps1) $ "


By the way, ~/.bash_aliases is intended for shell aliases, so it's a weird place to put your PS1. Personally I would put it in ~/.bashrc instead.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 at 19:44

























answered Nov 19 at 17:49









wjandrea

7,81642258




7,81642258












  • Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
    – janw
    Nov 19 at 21:43










  • Is there a way to check this source order?
    – janw
    Nov 19 at 21:46










  • Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
    – wjandrea
    Nov 19 at 21:53








  • 1




    @janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
    – wjandrea
    Nov 19 at 22:56












  • Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
    – janw
    Nov 20 at 8:31




















  • Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
    – janw
    Nov 19 at 21:43










  • Is there a way to check this source order?
    – janw
    Nov 19 at 21:46










  • Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
    – wjandrea
    Nov 19 at 21:53








  • 1




    @janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
    – wjandrea
    Nov 19 at 22:56












  • Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
    – janw
    Nov 20 at 8:31


















Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
– janw
Nov 19 at 21:43




Sorry, but I did use $() and not double quotes. That was an edit-error, based on a suggestion in the comments. I use the aliases file because I only want to edit/backup one file.
– janw
Nov 19 at 21:43












Is there a way to check this source order?
– janw
Nov 19 at 21:46




Is there a way to check this source order?
– janw
Nov 19 at 21:46












Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
– wjandrea
Nov 19 at 21:53






Are you sure you're using single quotes and not double quotes? I skimmed the edit history and always saw double quotes.
– wjandrea
Nov 19 at 21:53






1




1




@janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
– wjandrea
Nov 19 at 22:56






@janw for source order, the closest you could get is bash -x, which is pretty verbose, but come to think of it, this could also help diagnose the original problem, cause it will show every command it executes during startup
– wjandrea
Nov 19 at 22:56














Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
– janw
Nov 20 at 8:31






Ahh I misunderstood the remark about quotes. I was only looking at " __git_ps1" part. Now I replaced the PS1 with single quotes and now it works 🙌
– janw
Nov 20 at 8:31




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1094170%2fgit-ps1-not-found-but-does-exist%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ellipse (mathématiques)

Quarter-circle Tiles

Mont Emei