From 994f2875c1e99d7147c8ee17e2337ab1d6931a7a Mon Sep 17 00:00:00 2001 From: Arialdo Martini Date: Wed, 4 Feb 2015 08:22:19 +0100 Subject: [PATCH 1/2] WIP --- README.md | 12 ++++++++++++ prompt.sh | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b6f7f1b..07ff375 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,18 @@ Those are just default values. If you wish to use another glyph for untracked fi in your shell startup file. +--- +#### With Bash the last arrow looks very bad, like this + +![oh-my-git](https://cloud.githubusercontent.com/assets/6009528/6031476/0b9bfe2c-ac00-11e4-898a-324a71be6cb5.png) + +**A**: Unfortunately, I yet 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. +As a consequence, when printing the last arrow , the foreground and background colors must be explicitly set. This is unfortunate, because if the terminal is using a different background color, the result is bad, as showed in the above screenshot. + +Luckily, you can override the colors used to render the last arrow, using the variable `omg_last_arrow_color`. + +For example, if the termina + --- #### On OS X, I configured iTerm2 with the patched font, but the prompt is still broken. diff --git a/prompt.sh b/prompt.sh index ab9c385..f613756 100644 --- a/prompt.sh +++ b/prompt.sh @@ -28,7 +28,8 @@ if [ -n "${BASH_VERSION}" ]; then : ${omg_default_color_on:='\[\033[1;37m\]'} : ${omg_default_color_off:='\[\033[0m\]'} - + : ${omg_last_arrow_color:='\e[0;31m\e[40m'} + PROMPT='$(build_prompt)' RPROMPT='%{$reset_color%}%T %{$fg_bold[white]%} %n@%m%{$reset_color%}' @@ -158,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+="${red_on_black}${reset}\n" + prompt+="${omg_last_arrow_color}${red}${reset}\n" prompt+="$(eval_prompt_callback_if_present)" prompt+="${omg_second_line}" else From 0d65f53b44a8727ea377be589f6a402ac3d3845e Mon Sep 17 00:00:00 2001 From: Arialdo Martini Date: Wed, 4 Feb 2015 09:14:34 +0100 Subject: [PATCH 2/2] Fixing bash colors for non-back backgrounds --- README.md | 32 +++++++++++++++++++++++++++----- prompt.sh | 4 ++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 07ff375..9813c08 100644 --- a/README.md +++ b/README.md @@ -152,18 +152,40 @@ Those are just default values. If you wish to use another glyph for untracked fi in your shell startup file. --- -#### With Bash the last arrow looks very bad, like this +#### 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 yet 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. -As a consequence, when printing the last arrow , the foreground and background colors must be explicitly set. This is unfortunate, because if the terminal is using a different background color, the result is bad, as showed in the above screenshot. +**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. -Luckily, you can override the colors used to render the last arrow, using the variable `omg_last_arrow_color`. +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. -For example, if the termina +Luckily, 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. **A**: iTerm2 preferences have 2 sections for setting the font: one for `Regular Font` and one for `Non-ASCII Font`. diff --git a/prompt.sh b/prompt.sh index f613756..c28c660 100644 --- a/prompt.sh +++ b/prompt.sh @@ -28,7 +28,7 @@ if [ -n "${BASH_VERSION}" ]; then : ${omg_default_color_on:='\[\033[1;37m\]'} : ${omg_default_color_off:='\[\033[0m\]'} - : ${omg_last_arrow_color:='\e[0;31m\e[40m'} + : ${omg_last_symbol_color:='\e[0;31m\e[40m'} PROMPT='$(build_prompt)' RPROMPT='%{$reset_color%}%T %{$fg_bold[white]%} %n@%m%{$reset_color%}' @@ -159,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_arrow_color}${red}${reset}\n" + prompt+="${omg_last_symbol_color}${reset}\n" prompt+="$(eval_prompt_callback_if_present)" prompt+="${omg_second_line}" else