Skip to content

Commit

Permalink
✨ Add bold prompt switcher command
Browse files Browse the repository at this point in the history
  • Loading branch information
diogocavilha committed Apr 11, 2023
1 parent 150a27c commit 770a9a3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

> Any trouble, please visit the [troubleshooting page](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)
## v7.3.0
- Add `fancygit --enable-bold-prompt` command to show prompt in bold font.
- Add `fancygit --disable-bold-prompt` command to show prompt in regular font.

## v7.2.0
- Fix theme human prompt space between symbols.

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ Type `fancygit -h` to see all available feature switchers on **"FEATURE SWITCHER
| fancygit --disable-double-line | Show a single line prompt.
| fancygit --enable-rich-notification | Show notification area with icons.
| fancygit --disable-rich-notification | Show notification area with simple symbols.
| fancygit --enable-bold-prompt | Show bold prompt font.
| fancygit --disable-bold-prompt | Show regular prompt font.
| fancygit --set-user-name {name} | Set the user name.
| fancygit --unset-user-name | Restore the user name to default.
| fancygit --set-host-name {name} | Set the host name.
Expand Down
1 change: 1 addition & 0 deletions app_config_sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ separator:
ps2:➜
user_name:
host_name:
bold_prompt:false
fresh_file
2 changes: 2 additions & 0 deletions commands-handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ case "$1" in
"--disable-double-line") fancygit_config_save "double_line" "false";;
"--enable-rich-notification") fancygit_config_save "show_rich_notification" "true";;
"--disable-rich-notification") fancygit_config_save "show_rich_notification" "false";;
"--enable-bold-prompt") fancygit_config_save "bold_prompt" "true";;
"--disable-bold-prompt") fancygit_config_save "bold_prompt" "false";;

# Set Name and Host.
"--set-user-name") fancygit_config_save "user_name" "$2";;
Expand Down
2 changes: 2 additions & 0 deletions fancygit-completion
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ _fancygit() {
--disable-double-line \
--enable-rich-notification \
--disable-rich-notification \
--enable-bold-prompt \
--disable-bold-prompt \
--set-user-name \
--unset-user-name \
--set-host-name \
Expand Down
2 changes: 2 additions & 0 deletions help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ FEATURE SWITCHER COMMANDS:
fancygit --disable-double-line Show a single line prompt.
fancygit --enable-rich-notification Show notification area with icons.
fancygit --disable-rich-notification Show notification area with simple symbols.
fancygit --enable-bold-prompt Show bold prompt font.
fancygit --disable-bold-prompt Show regular prompt font.
THEME COMMANDS:
fancygit --theme-default Change prompt to the default theme.
Expand Down
13 changes: 11 additions & 2 deletions themes/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ fancygit_theme_builder() {
local none="\\[\\e[39m\\]"
local bold_none="\\[\\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)"
fi

# Prompt style
local separator
Expand Down Expand Up @@ -110,7 +119,7 @@ fancygit_theme_builder() {
# 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="${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_double_line} "
PS1="${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_double_line}${normal_prompt} "
return
fi

Expand Down Expand Up @@ -142,7 +151,7 @@ fancygit_theme_builder() {
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="${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${prompt_double_line} "
PS1="${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${prompt_double_line}${normal_prompt} "
}

# Here's where the magic happens!
Expand Down
12 changes: 10 additions & 2 deletions themes/human.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ fancygit_theme_builder() {
local venv_name
local prompt_symbol
local prompt_path
local bold_prompt=""
local normal_prompt=""

local user_name
user_name=$(fancygit_config_get "user_name" "\\u")
Expand Down Expand Up @@ -104,6 +106,12 @@ fancygit_theme_builder() {
prompt_user_at_host="${user}${user_name}${color_reset}${at} at ${color_reset}${host}${host_name}${color_reset}${user_at_host_end} in "
fi

if fancygit_config_is "bold_prompt" "true"
then
bold_prompt="$(tput bold)"
normal_prompt="$(tput sgr0)"
fi

# If we have a branch name, it means we are in a git repo, so we need to make some changes on PS1.
branch_name=$(fancygit_git_get_branch)

Expand All @@ -117,11 +125,11 @@ fancygit_theme_builder() {
prompt_path="${path_git}${path_sign}${path_end}"
prompt_branch="${branch}${branch_name}${branch_end}"
PS1="${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name} on ${prompt_branch} $(fancygit_get_notification_area "$is_rich_notification")"
PS1="${PS1}${prompt_symbol}${is_double_line} "
PS1="${bold_prompt}${PS1}${prompt_symbol}${is_double_line}${normal_prompt} "
return
fi

PS1="${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name} ${prompt_symbol}${is_double_line} "
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
10 changes: 9 additions & 1 deletion themes/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ fancygit_theme_builder() {
local venv_name
local branch_area
local where
local bold_prompt=""
local normal_prompt=""

if fancygit_config_is "bold_prompt" "true"
then
bold_prompt="$(tput bold)"
normal_prompt="$(tput sgr0)"
fi

# Get theme config.
prompt_time="$(fancygit_theme_get_time)"
Expand All @@ -65,7 +73,7 @@ fancygit_theme_builder() {
venv_name="($venv_name) "
fi

PS1="${venv_name}${prompt_time}${user_at_host}$where\$${branch_area}${is_double_line} "
PS1="${bold_prompt}${venv_name}${prompt_time}${user_at_host}$where\$${branch_area}${is_double_line}${normal_prompt} "
}

# ----------------------------------------------------------------------------------------------------------------------
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.2.0"
export FANCYGIT_VERSION="7.3.0"

0 comments on commit 770a9a3

Please sign in to comment.