bash-git-prompt icon indicating copy to clipboard operation
bash-git-prompt copied to clipboard

Strange character

Open alexrocco opened this issue 11 years ago • 8 comments

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.

image

alexrocco avatar Aug 05 '14 01:08 alexrocco

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)

magicmonty avatar Aug 05 '14 07:08 magicmonty

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

kenny-evitt avatar Sep 14 '16 15:09 kenny-evitt

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"

kenny-evitt avatar Sep 15 '16 16:09 kenny-evitt

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

magicmonty avatar Sep 15 '16 17:09 magicmonty

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/.

scotlynhatt avatar Jan 17 '17 16:01 scotlynhatt

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).

seangwright avatar Apr 27 '17 05:04 seangwright

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"

fastzombies avatar May 11 '17 20:05 fastzombies

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.

JeffMill avatar Mar 11 '20 22:03 JeffMill