Skip to content

Commit

Permalink
Merge pull request #137 from diogocavilha/fix/bold-prompt
Browse files Browse the repository at this point in the history
Fix/bold prompt
  • Loading branch information
diogocavilha authored Apr 14, 2023
2 parents dee4cc0 + d998ca6 commit b2c66eb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

> Any trouble, please visit the [troubleshooting page](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)
## v7.5.3
- Fix 4 stuck characters when navigating through history commands.
- Fix prompt color leak for default theme.
- Fix human theme double space after notification area.

## v7.5.2
- Improve human dracula color-scheme branch color.

Expand Down
2 changes: 1 addition & 1 deletion theme-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ __fancygit_get_poor_notification_area() {
# Trim notification_area content
notification_area=$(echo "$notification_area" | sed -e 's/[[:space:]]*$//' | sed -e 's/^[[:space:]]*//')

echo "${notification_area//[[:space:]]*$/} "
echo "${notification_area//[[:space:]]*$/}"
return
fi

Expand Down
30 changes: 15 additions & 15 deletions themes/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ fancygit_theme_builder() {
local branch_color_bg_tag="\\[\\e[48;5;${FANCYGIT_COLOR_SCHEME_BRANCH_BACKGROUND}m\\]"
local branch_color_font_tag="\\[\\e[38;5;${FANCYGIT_COLOR_SCHEME_BRANCH_FOREROUND}m\\]"
local none="\\[\\e[39m\\]"
local bold_none="\\[\\e[0m\\]"
local clear="\\[\\e[0m\\]"
local bg_none="\\[\\e[49m\\]"
local bold_prompt=""
local normal_prompt=""

if fancygit_config_is "bold_prompt" "true"
then
bold_none=""
bold_prompt="$(tput bold)"
normal_prompt="$(tput sgr0)"
clear=""
bold_prompt="\\[\\e[1m\\]"
normal_prompt="\\[\\e[0m\\]"
fi

# Prompt style
Expand All @@ -68,16 +68,16 @@ fancygit_theme_builder() {
local at="${at_color_font_tag}"
local host="${host_color_font_tag}"
local user_at_host="${user_at_host_color_bg_tag}"
local user_at_host_end="${bold_none}${bg_none}${user_at_host_color_tag}${user_symbol_color_bg_tag}${separator}"
local user_at_host_end="${user_at_host_color_tag}${user_symbol_color_bg_tag}${separator}"
local user_symbol="${user_symbol_color_bg_tag}${user_symbol_color_font_tag}"
local user_symbol_end="${none}${bold_none}${bg_none}${user_symbol_color_tag}${workdir_color_bg_tag}${separator}"
local user_symbol_end="${none}${user_symbol_color_tag}${workdir_color_bg_tag}${separator}"
local path="${workdir_color_bg_tag}${workdir_color_font_tag}"
local path_git="${workdir_color_bg_tag}${workdir_color_font_tag} ${icon_git_repo} "
local path_end="${none}${bold_none}"
local path_end="${none}"
local branch="${workdir_color_tag}${branch_color_bg_tag}${separator}${branch_color_font_tag}"
local branch_end="${branch_color_tag}${bg_none}${separator}${bold_none}${none}"
local branch_end="${branch_color_tag}${bg_none}${separator}${none}"
local time="${time_color_bg_tag}${time_color_tag}"
local time_end="${bold_none}${bg_none}"
local time_end=""
local prompt_time
local prompt_user
local prompt_env
Expand All @@ -93,7 +93,7 @@ fancygit_theme_builder() {
# This prevents a weird presentation. Life is not easy :/
if [[ "$FANCYGIT_COLOR_SCHEME_TIME_BACKGROUND" != "$FANCYGIT_COLOR_SCHEME_USER_AT_HOST_BACKGROUND" && "" != "$time_raw" ]]
then
time_end="${bold_none}${bg_none}${time_symbol_color_tag}${user_at_host_color_bg_tag}${separator} "
time_end="${time_symbol_color_tag}${user_at_host_color_bg_tag}${separator} "
fi

local user_name
Expand Down Expand Up @@ -123,8 +123,8 @@ fancygit_theme_builder() {
then
# No branch found, so we're not in a git repo.
prompt_env=$(__fancygit_get_venv_icon)
prompt_path="${path}${prompt_env} ${prompt_path} ${path_end}${workdir_color_tag}${separator}${none}"
PS1="${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_double_line}${normal_prompt} "
prompt_path="${path}${prompt_env} ${prompt_path} ${path_end}${workdir_color_tag}${bg_none}${separator}${none}"
PS1="${clear}${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${clear}${normal_prompt}${prompt_double_line} "
return
fi

Expand All @@ -143,20 +143,20 @@ fancygit_theme_builder() {
if [ "" != "$(fancygit_git_get_status)" ]
then
branch="${workdir_color_tag}${branch_color_changed_files_bg_tag}${separator}${branch_color_changed_files_font_tag}"
branch_end="${bg_none}${bold_none}${branch_color_changed_files_tag}${separator}${none}"
branch_end="${branch_color_changed_files_tag}${bg_none}${separator}${none}"
fi

# Configure a specific background color to branch name, if it has staged files.
if [ "" != "$(fancygit_git_get_staged_files)" ]
then
branch="${workdir_color_tag}${branch_color_staged_files_bg_tag}${separator}${branch_color_staged_files_font_tag}"
branch_end="${bg_none}${bold_none}${branch_color_staged_files_tag}${separator}${none}"
branch_end="${branch_color_staged_files_tag}${bg_none}${separator}${none}"
fi

notification_area=$(fancygit_get_notification_area "$is_rich_notification")
prompt_path="${path_git}${notification_area} ${prompt_path} ${path_end}"
prompt_branch="${branch} $(fancygit_git_get_branch_icon "${branch_name}") ${branch_name} ${branch_end}"
PS1="${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${prompt_double_line}${normal_prompt} "
PS1="${clear}${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${clear}${normal_prompt}${prompt_double_line} "
}

# Here's where the magic happens!
Expand Down
6 changes: 3 additions & 3 deletions themes/human.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ fancygit_theme_builder() {

if fancygit_config_is "bold_prompt" "true"
then
bold_prompt="$(tput bold)"
normal_prompt="$(tput sgr0)"
bold_prompt="\\[\\e[1m\\]"
normal_prompt="\\[\\e[0m\\]"
fi

# If we have a branch name, it means we are in a git repo, so we need to make some changes on PS1.
Expand All @@ -140,7 +140,7 @@ fancygit_theme_builder() {
return
fi

PS1="${bold_prompt}${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name} ${prompt_symbol}${is_double_line}${normal_prompt} "
PS1="${bold_prompt}${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name}${prompt_symbol}${is_double_line}${normal_prompt} "
}

# Here's where the magic happens!
Expand Down
4 changes: 2 additions & 2 deletions themes/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ fancygit_theme_builder() {

if fancygit_config_is "bold_prompt" "true"
then
bold_prompt="$(tput bold)"
normal_prompt="$(tput sgr0)"
bold_prompt="\\[\\e[1m\\]"
normal_prompt="\\[\\e[0m\\]"
fi

# Get theme config.
Expand Down
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 11.17.2017

export FANCYGIT_VERSION="7.5.2"
export FANCYGIT_VERSION="7.5.3"

0 comments on commit b2c66eb

Please sign in to comment.