bash-git-prompt
bash-git-prompt copied to clipboard
Strange character
Hi!
I followed all the steps to install and seemingly everything worked correctly, but master's branch is always showing this way. Is this correct?
Thx, Alexandre Rocco.

It seems, that you use the Git shell in Windows.
The git bash in windows currently doesn't handles Unicode characters correctly,
See https://github.com/msysgit/msysgit/wiki/Git-for-Windows-Unicode-Support
All what you can do here, is to replace add a .git-prompt-colors file to your home directory and set the variables there with different markers (see git-prompt.colors.sh for examples)
Git Bash in Windows (now) supports Unicode characters mostly tho it seems like the fonts available in Git Bash don't support all of the characters used (by default) by bash-git-prompt. Here's what I added to my ~/.bashrc file to replace the characters unsupported by the font Consolas:
GIT_PROMPT_CONFLICTS="${Red}× " # the number of files in conflict
GIT_PROMPT_CHANGED="${Blue}+ " # the number of changed files
GIT_PROMPT_STASHED="${BoldBlue}▪ " # the number of stashed files/dir
GIT_PROMPT_CLEAN="${BoldGreen}√" # a colored flag indicating a "clean" repo
GIT_PROMPT_COMMAND_OK="${Green}√" # indicator if the last command returned with an exit code of 0
GIT_PROMPT_COMMAND_FAIL="${Red}×-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0
Sorry for spamming a long-closed issue, but for the sake of anyone from the future (including a version of myself), I moved the code in my last comment into ~/.git-prompt-colors.sh, as directed by the bash-git-prompt README, and wrapped it as follows (also as directed):
override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="Custom" # needed for reload optimization, should be unique
# Override prompt components with unsupported characters
GIT_PROMPT_CONFLICTS="${Red}× " # the number of files in conflict
GIT_PROMPT_CHANGED="${Blue}+ " # the number of changed files
GIT_PROMPT_STASHED="${BoldBlue}▪ " # the number of stashed files/dir
GIT_PROMPT_CLEAN="${BoldGreen}√" # a colored flag indicating a "clean" repo
GIT_PROMPT_COMMAND_OK="${Green}√" # indicator if the last command returned with an exit code of 0
GIT_PROMPT_COMMAND_FAIL="${Red}×-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0
}
# load the theme
reload_git_prompt_colors "Custom"
No problem, I am currently playing around with a more generic solution, so the we don't have to duplicate every theme for different systems
The font limitation shows up in the default Ubuntu shell on Windows 10 as well but I was able to see the glyph characters by simply using DejaVu Mono https://dejavu-fonts.github.io/.
What @scotlynhatt means is download the font on windows, install it and then select it from the font menu for the WSL window (right click on the title bar -> properties -> font).
FWIW anyone on a system that has missing or mis-mapped unicode with no hope of changing it, I put this in my ~/.git-prompt-colors.sh (thanks @kenny-evitt for the tip):
override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="Custom" # needed for reload optimization, should be unique
# Override prompt components with unsupported characters
GIT_PROMPT_CONFLICTS="${Red}× " # the number of files in conflict
GIT_PROMPT_CHANGED="${Blue}+ " # the number of changed files
GIT_PROMPT_STASHED="${BoldBlue}s " # the number of stashed files/dir
GIT_PROMPT_CLEAN="${BoldGreen}c" # a colored flag indicating a "clean" repo
GIT_PROMPT_COMMAND_OK="${Green}ok" # indicator if the last command returned with an exit code of 0
GIT_PROMPT_COMMAND_FAIL="${Red}×-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0
}
# load the theme
reload_git_prompt_colors "Custom"
In addition to adding that to ~/.git-prompt-colors.sh I also had to add
GIT_PROMPT_THEME="Custom"
to my ~/.bashrc -- the documentation here says to use GIT_PROMPT_THEME_NAME, but that didn't work for me.