__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?
command-line bash prompt ps1
|
show 8 more comments
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?
command-line bash prompt ps1
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 whenPS1
is set, not whenPS1
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 thatcommand 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 sourcinggit-sh-prompt
or your file~/.local/git-completion.bash
(shown in an older version of your post)).
– PerlDuck
Nov 19 at 13:44
|
show 8 more comments
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?
command-line bash prompt ps1
~/.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?
command-line bash prompt ps1
command-line bash prompt ps1
edited Nov 22 at 20:44
wjandrea
7,90342258
7,90342258
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 whenPS1
is set, not whenPS1
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 thatcommand 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 sourcinggit-sh-prompt
or your file~/.local/git-completion.bash
(shown in an older version of your post)).
– PerlDuck
Nov 19 at 13:44
|
show 8 more comments
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 whenPS1
is set, not whenPS1
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 thatcommand 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 sourcinggit-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
|
show 8 more comments
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.
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 isbash -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
|
show 1 more comment
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.
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 isbash -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
|
show 1 more comment
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.
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 isbash -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
|
show 1 more comment
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.
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.
edited Nov 20 at 19:44
answered Nov 19 at 17:49
wjandrea
7,90342258
7,90342258
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 isbash -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
|
show 1 more comment
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 isbash -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
|
show 1 more comment
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 whenPS1
is set, not whenPS1
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 sourcinggit-sh-prompt
or your file~/.local/git-completion.bash
(shown in an older version of your post)).– PerlDuck
Nov 19 at 13:44