git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bash __git_ps1 line wrapping issue on OSX

From
AMAdam Moss <admoss1980@btinternet.com>
Date
Jul 23, 2015, 07:54 UTC
Message-ID
<loom.20150723T095031-240@post.gmane.org>

I have sourced git-prompt.sh (copied from https://github.com/git/git/tree/master/contrib/completion) and included it in my .bashrc as follows:

GIT_PS1_SHOWDIRTYSTATE=true; GIT_PS1_SHOWUPSTREAM="verbose"; GIT_PS1_SHOWCOLORHINTS=true;

PROMPT_COMMAND='__git_ps1 "# \u@\h:\w" " \$ "';

Under CentOS etc. this works fine. On OSX however, when dealing with a nested folder structure that causes line wrapping, the formatting of the bit where you type goes do-lally-tap. Character spacing is wrong (like each character is tab separated) and once it hits the end of the line it starts to overwrite itself (but only the last character). There is a screen shot of the issue on the StackOverflow question I've asked about this at http://stackoverflow.com/questions/31561969/bash-git-ps1-line-wrapping-issue-on-osx.

The code that __git_ps1 has generated for PS1 is:

# \u@\h:\w (\[\e[32m\]${__git_ps1_branch_name}\[\e[0m\] \[\e[31m\]*\[\e[0m\] u=) $

Has anyone experienced this and / or could suggest a solution?

If I comment out the GIT_PS1_SHOWCOLORHINTS directive it works, albeit without the colour highlighting, so I'm guessing there is something amiss in the control sequences somewhere.

Thanks,
Adam M.
Message 1 of 1 in “Bash __git_ps1 line wrapping issue on OSX”
  1. Adam MossJul 23, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.