From 770a9a3402ef96fcf0929f4b8ad21f3db54c300a Mon Sep 17 00:00:00 2001 From: Diogo Alexsander Cavilha Date: Tue, 11 Apr 2023 15:28:00 -0300 Subject: [PATCH] :sparkles: Add bold prompt switcher command --- CHANGELOG.md | 4 ++++ README.md | 2 ++ app_config_sample | 1 + commands-handler.sh | 2 ++ fancygit-completion | 2 ++ help.sh | 2 ++ themes/default.sh | 13 +++++++++++-- themes/human.sh | 12 ++++++++++-- themes/simple.sh | 10 +++++++++- version.sh | 2 +- 10 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c286ea..5030922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index f978ebf..0d7c9f0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/app_config_sample b/app_config_sample index 09e7dc3..b2f2478 100644 --- a/app_config_sample +++ b/app_config_sample @@ -10,4 +10,5 @@ separator: ps2:➜ user_name: host_name: +bold_prompt:false fresh_file diff --git a/commands-handler.sh b/commands-handler.sh index 508b7ec..242efbb 100755 --- a/commands-handler.sh +++ b/commands-handler.sh @@ -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";; diff --git a/fancygit-completion b/fancygit-completion index 843ff3a..ea8ca9a 100644 --- a/fancygit-completion +++ b/fancygit-completion @@ -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 \ diff --git a/help.sh b/help.sh index e6ddc5a..dcbe6fa 100644 --- a/help.sh +++ b/help.sh @@ -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. diff --git a/themes/default.sh b/themes/default.sh index 32cb6ca..f3ffcc7 100644 --- a/themes/default.sh +++ b/themes/default.sh @@ -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 @@ -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 @@ -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! diff --git a/themes/human.sh b/themes/human.sh index 019e595..c77d996 100644 --- a/themes/human.sh +++ b/themes/human.sh @@ -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") @@ -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) @@ -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! diff --git a/themes/simple.sh b/themes/simple.sh index fb10158..417532e 100644 --- a/themes/simple.sh +++ b/themes/simple.sh @@ -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)" @@ -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} " } # ---------------------------------------------------------------------------------------------------------------------- diff --git a/version.sh b/version.sh index 71270c9..f5aad46 100644 --- a/version.sh +++ b/version.sh @@ -3,4 +3,4 @@ # Author: Diogo Alexsander Cavilha # Date: 11.17.2017 -export FANCYGIT_VERSION="7.2.0" +export FANCYGIT_VERSION="7.3.0"