Bash __git_ps1 line wrapping issue on OSX
From: Adam Moss <hidden>
Date: 2016-06-15 23:05:51
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.