Adam M.
Adam M.

Reputation: 773

Bash __git_ps1 line wrapping issue on OSX

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 as per the following:

Image showing formatting issue

The code that __git_ps1 has generated 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.

Upvotes: 1

Views: 203

Answers (1)

Adam M.
Adam M.

Reputation: 773

I eventually got this one sorted, but had to switch to an updated version of bash to do it:

brew install bash
sudo vi /etc/shells
chsh -s /usr/local/bin/bash

Upvotes: 2

Related Questions