From 825ac431dd3e7c6e6f40dae6762036d14062b4c2 Mon Sep 17 00:00:00 2001 From: Diogo Alexsander Cavilha Date: Tue, 11 Apr 2023 17:09:48 -0300 Subject: [PATCH] :sparkles: Add command to enable/disable host name on prompt New commands: - fancygit --disable-host-name - fancygit --enable-host-name --- README.md | 2 ++ app_config_sample | 1 + commands-handler.sh | 2 ++ fancygit-completion | 2 ++ help.sh | 2 ++ themes/default.sh | 5 +++++ themes/human.sh | 5 +++++ themes/simple.sh | 5 +++++ version.sh | 2 +- 9 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d7c9f0..d997550 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,8 @@ Type `fancygit -h` to see all available feature switchers on **"FEATURE SWITCHER | 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 --enable-host-name | Show host name. +| fancygit --disable-host-name | Hide host name. | 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 b2f2478..57dc54a 100644 --- a/app_config_sample +++ b/app_config_sample @@ -11,4 +11,5 @@ ps2:➜ user_name: host_name: bold_prompt:false +show_host_prompt:false fresh_file diff --git a/commands-handler.sh b/commands-handler.sh index 242efbb..92c7041 100755 --- a/commands-handler.sh +++ b/commands-handler.sh @@ -40,6 +40,8 @@ case "$1" in "--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";; + "--enable-host-name") fancygit_config_save "show_host_prompt" "true";; + "--disable-host-name") fancygit_config_save "show_host_prompt" "false";; # Set Name and Host. "--set-user-name") fancygit_config_save "user_name" "$2";; diff --git a/fancygit-completion b/fancygit-completion index ea8ca9a..6e2d765 100644 --- a/fancygit-completion +++ b/fancygit-completion @@ -27,6 +27,8 @@ _fancygit() { --disable-rich-notification \ --enable-bold-prompt \ --disable-bold-prompt \ + --enable-host-name \ + --disable-host-name \ --set-user-name \ --unset-user-name \ --set-host-name \ diff --git a/help.sh b/help.sh index dcbe6fa..80a3bab 100644 --- a/help.sh +++ b/help.sh @@ -35,6 +35,8 @@ FEATURE SWITCHER COMMANDS: 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 --enable-host-name Show host name. + fancygit --disable-host-name Hide host name. THEME COMMANDS: fancygit --theme-default Change prompt to the default theme. diff --git a/themes/default.sh b/themes/default.sh index f3ffcc7..67021cf 100644 --- a/themes/default.sh +++ b/themes/default.sh @@ -113,6 +113,11 @@ fancygit_theme_builder() { prompt_user="${user_at_host}${user}${user_name}${none}${at}@${none}${host}${host_name}${none} ${user_at_host_end}" fi + if fancygit_config_is "show_host_prompt" "false" + then + prompt_user="${user_at_host}${user}${user_name}${none}${none} ${user_at_host_end}" + fi + branch_name=$(fancygit_git_get_branch) if [ "" = "$branch_name" ] then diff --git a/themes/human.sh b/themes/human.sh index c77d996..65626bd 100644 --- a/themes/human.sh +++ b/themes/human.sh @@ -106,6 +106,11 @@ 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 "show_host_prompt" "false" + then + prompt_user_at_host="${user}${user_name}${color_reset} in " + fi + if fancygit_config_is "bold_prompt" "true" then bold_prompt="$(tput bold)" diff --git a/themes/simple.sh b/themes/simple.sh index 417532e..89f2239 100644 --- a/themes/simple.sh +++ b/themes/simple.sh @@ -68,6 +68,11 @@ fancygit_theme_builder() { user_at_host="$user$at$host:" fi + if fancygit_config_is "show_host_prompt" "false" + then + user_at_host="$user:" + fi + if [ "" != "$venv_name" ] then venv_name="($venv_name) " diff --git a/version.sh b/version.sh index f5aad46..271e32f 100644 --- a/version.sh +++ b/version.sh @@ -3,4 +3,4 @@ # Author: Diogo Alexsander Cavilha # Date: 11.17.2017 -export FANCYGIT_VERSION="7.3.0" +export FANCYGIT_VERSION="7.4.0"