bash-prompt-generator
bash-prompt-generator copied to clipboard
The Tool Is Generating A PS1 String With Unexpected Leading Characters
This prompt:
- PS1='[\e[0;1;38;5;212m]$(git branch 2>/dev/null | grep '"'"'^*'"'"' | colrm 1 2) [\e[0;1;38;5;46m]\u[\e[0;38;5;227m]@[\e[0;1;38;5;46m]\h[\e[0m]:[\e[0;1;38;5;45m]/[\e[0;1;38;5;45m]\W[\e[0;1;38;5;226m]# [\e[0m]'
is resulting in the following prompt when set in my .bashrc file. Screenshot of the generator page below
- ]main jeff@machine:/var$
Where are these two leading characters coming from?
- ]
Note: view this in plaintext mode so the markdown editor doesn't render them differently. This is also important because the renderer is removing non-escaped backslashes
I cannot reproduce this issue. The prompt string works perfectly fine for me:

Can you post the output from git branch 2>/dev/null?
You are seeing the issue but the characters aren’t rendering.
Notice how your prompt is offset two spaces to the right?
I see the same thing on my MacBook bash terminal. The original issue was seen on WSL and somehow that environment is rendering the special characters as opposed to just spaces.
On Sep 13, 2022, at 00:54, Tim @.***> wrote:
I cannot reproduce this issue. The prompt string works perfectly fine for me: https://user-images.githubusercontent.com/13003924/189843301-030baf73-0a99-4b6f-94f1-218fdf2ab7c5.png Can you post the output from git branch 2>/dev/null?
— Reply to this email directly, view it on GitHub https://github.com/Scriptim/bash-prompt-generator/issues/13#issuecomment-1245036441, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB72CEWC66H2WOZSM43F7JLV6AXL7ANCNFSM6AAAAAAQK6QDWU. You are receiving this because you authored the thread.
If I remove the GIt branch portion, everything looks fine. Please see the attached screenshot.
On Sep 13, 2022, at 00:54, Tim @.***> wrote:
I cannot reproduce this issue. The prompt string works perfectly fine for me: https://user-images.githubusercontent.com/13003924/189843301-030baf73-0a99-4b6f-94f1-218fdf2ab7c5.png Can you post the output from git branch 2>/dev/null?
— Reply to this email directly, view it on GitHub https://github.com/Scriptim/bash-prompt-generator/issues/13#issuecomment-1245036441, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB72CEWC66H2WOZSM43F7JLV6AXL7ANCNFSM6AAAAAAQK6QDWU. You are receiving this because you authored the thread.
Notice how your prompt is offset two spaces to the right?
The prompt ist offset by one space. This is the space character element that comes between the Git branch and the username. It appears to be an offset here only because I was in a directory that does not contain a git repo. In a git repository, the prompt looks like this:

Can you show me the output when you manually run git branch | grep '^*' | cat -A in the according directory?
@.***:~/projects/tmp$ git status On branch test-branch
No commits yet
nothing to commit (create/copy files and use "git add" to track) @.:~/projects/tmp$ git branch | grep '^' | cat -A cat: illegal option -- A usage: cat [-belnstuv] [file ...] @.*:~/projects/tmp$
On Sep 14, 2022, at 01:33, Tim @.***> wrote:
git branch | grep '^*' | cat -A
That's odd. What platform are you on exactly (operating system version, bash version, terminal software)?
Which output does git branch | grep '^*' produce (without the cat pipe which apparently has no -A option in your system's implementation)?
Thats he odd thing. ‘Git branch’ returns nothing at all even by itself. I am looking in to that. You can probably close this ticket. I have found an alternate PS1 builder that does what I need.
Thanks for all your time and help; I really apprecitate it.
On Sep 14, 2022, at 13:31, Tim @.***> wrote:
git branch | grep '^*'
I have found an alternate PS1 builder that does what I need.
Just out of interest, could you show me the working PS1 string from the other tool so I can see what that one does differently?