Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix last character having black background #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,46 +169,6 @@ Those are just default values. If you wish to use another glyph for untracked fi

in your shell startup file.

---
#### With Bash the last symbol looks very bad, like this

![oh-my-git](https://cloud.githubusercontent.com/assets/6009528/6031476/0b9bfe2c-ac00-11e4-898a-324a71be6cb5.png)

**A**: Unfortunately, I haven't find a way to tell bash "*print the next symbol using the background color currently used by the terminal*" and as far as I know [there's no way to achieve this result](http://unix.stackexchange.com/questions/1755/change-the-ps1-color-based-on-the-background-color#tab-top). Zsh is not affected by this issue, but bash is.

As a consequence, when printing the last symbol, oh-my-git has no choice but setting explicitly the foreground and background colors. Currently, the standard background color is black. This is unfortunate, because if the terminal uses a different background color than black, the result is bad, as showed in the above screenshot.

A smart solution is the one proposed by [@Sgiath](https://github.com/Sgiath): in the color palette set the first color (the one in the top-left corner) same as background color, like this

![oh-my-git](https://cloud.githubusercontent.com/assets/6009528/6039646/454c965e-ac69-11e4-8f80-37425181d04b.png)

This in fact sets the "black" color to the same color used as the terminal background.


If for any reasons you cannot change the palette, you can override the colors used to render the last symbol with the variable `omg_last_symbol_color`.

For example, if the terminal is using a gray background, you can add a

```
background=240
red='\e[0;31m'
omg_last_symbol_color="${red}\[\033[48;5;${background}m\]"
```

to your `.bashrc` and fix the issue by choosing the right value for `background`.

You can use

```
foreground=160
background=240
omg_last_symbol_color="\[\033[38;5;${foreground}m\]\[\033[48;5;${background}m\]"
```

if you want a more detailed control on the colors.

Finding the right value is not trivial. Please, refer to [this page](http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux) for a the 256 colors code table.

---

#### On OS X, I configured iTerm2 with the patched font, but the prompt is still broken.
Expand Down
3 changes: 1 addition & 2 deletions prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ if [ -n "${BASH_VERSION}" ]; then

: ${omg_default_color_on:='\[\033[1;37m\]'}
: ${omg_default_color_off:='\[\033[0m\]'}
: ${omg_last_symbol_color:='\e[0;31m\e[40m'}

PROMPT='$(build_prompt)'
RPROMPT='%{$reset_color%}%T %{$fg_bold[white]%} %n@%m%{$reset_color%}'
Expand Down Expand Up @@ -160,7 +159,7 @@ if [ -n "${BASH_VERSION}" ]; then
fi
fi
prompt+=$(enrich_append ${is_on_a_tag} "${omg_is_on_a_tag_symbol} ${tag_at_current_commit}" "${black_on_red}")
prompt+="${omg_last_symbol_color}${reset}\n"
prompt+="${reset}${red}${reset}\n"
prompt+="$(eval_prompt_callback_if_present)"
prompt+="${omg_second_line}"
else
Expand Down