Git for Windows: Upgrade to 2.7.0
I updated yesterday from msysgit 1.9.5 to git for windows 2.7.0
During the install I happened to choose the mintty option without really understanding what it meant. Although it came with fancy GUI options like bright colors, drag to resize the window, and adjustable window transparancy, a couple of things threw me.
Bash command prompt hangs
Out of the box, the git bash shell is configured to show some useful information on the command prompt, including:
- current username;
- current machine name;
- whether it’s running as 32- or 64- bit;
- the current path; and (if the present working directory is in a git repo)
- “it’s not a number”;
- the current branch;
Wait a moment, you might ask, what is “it’s not a number” doing in that list? Well, that was my experience:
dalpert@machine-name MINGW64 /d/dev/git/repo-nameit's not a number (patch-8.21.3)
$ <enter>
<enter>
DAlpert@machine-name MINGW64 /d/dev/git/repo-nameit's not a number (patch-8.21.3)
$ <enter>
4<enter>
DAlpert@machine-name MINGW64 /d/dev/git/repo-nameit's a number (patch-8.21.3)
$
It took me a while to figure out the following:
- the command prompt was pausing after every command, as it was waiting for input
- entering a number would change the output to “it’s a number”, otherwise it would insist that “it’s not a number”
I went spelunking.
On starting up a git bash console:
C:\Program Files\Git\etc\bash.bashrc
executes callingC:\Program Files\Git\etc\profile.d\git-prompt.sh
This /etc/profile.d/git-prompt.sh
file sets the prompt:
if test -f /etc/profile.d/git-sdk.sh
then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
TITLEPREFIX=$MSYSTEM
fi
PS1='\[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]' # set window title
PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[32m\]' # change to green
PS1="$PS1"'\u@\h ' # user@host<space>
PS1="$PS1"'\[\033[35m\]' # change to purple
PS1="$PS1"'$MSYSTEM ' # show MSYSTEM
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1"'\w' # current working directory
if test -z "$WINELOADERNOEXEC"
then
GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
if test -f "$COMPLETION_PATH/git-prompt.sh"
then
. "$COMPLETION_PATH/git-completion.bash"
. "$COMPLETION_PATH/git-prompt.sh"
PS1="$PS1"'\[\033[36m\]' # change color to cyan
PS1="$PS1"'`__git_ps1`' # bash function
fi
fi
PS1="$PS1"'\[\033[0m\]' # change color
PS1="$PS1"'\n' # new line
PS1="$PS1"'$ ' # prompt: always $
If you follow this file through you will notice that line 25 loads another git-prompt.sh
which configures bash function __git_ps1
Long and short of it is, you have to apply this change.
Fix up bash vim cursor
Thanks to the Tips wiki page of the mintty project on google code I found the following:
Mode-dependent cursor in vim
Mintty supports control sequences for changing cursor style. These can be used to configure vim such that the cursor changes depending on mode. For example, with the following lines in
~/.vimrc
, vim will show a block cursor in normal mode and a line cursor in insert mode:let &t_ti.="\e[1 q" let &t_SI.="\e[5 q" let &t_EI.="\e[1 q" let &t_te.="\e[0 q"