Skip to content

Commit 770a9a3

Browse files
committed
✨ Add bold prompt switcher command
1 parent 150a27c commit 770a9a3

File tree

10 files changed

+44
-6
lines changed

10 files changed

+44
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
> Any trouble, please visit the [troubleshooting page](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)
44
5+
## v7.3.0
6+
- Add `fancygit --enable-bold-prompt` command to show prompt in bold font.
7+
- Add `fancygit --disable-bold-prompt` command to show prompt in regular font.
8+
59
## v7.2.0
610
- Fix theme human prompt space between symbols.
711

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ Type `fancygit -h` to see all available feature switchers on **"FEATURE SWITCHER
189189
| fancygit --disable-double-line | Show a single line prompt.
190190
| fancygit --enable-rich-notification | Show notification area with icons.
191191
| fancygit --disable-rich-notification | Show notification area with simple symbols.
192+
| fancygit --enable-bold-prompt | Show bold prompt font.
193+
| fancygit --disable-bold-prompt | Show regular prompt font.
192194
| fancygit --set-user-name {name} | Set the user name.
193195
| fancygit --unset-user-name | Restore the user name to default.
194196
| fancygit --set-host-name {name} | Set the host name.

app_config_sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ separator:
1010
ps2:➜
1111
user_name:
1212
host_name:
13+
bold_prompt:false
1314
fresh_file

commands-handler.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ case "$1" in
3838
"--disable-double-line") fancygit_config_save "double_line" "false";;
3939
"--enable-rich-notification") fancygit_config_save "show_rich_notification" "true";;
4040
"--disable-rich-notification") fancygit_config_save "show_rich_notification" "false";;
41+
"--enable-bold-prompt") fancygit_config_save "bold_prompt" "true";;
42+
"--disable-bold-prompt") fancygit_config_save "bold_prompt" "false";;
4143

4244
# Set Name and Host.
4345
"--set-user-name") fancygit_config_save "user_name" "$2";;

fancygit-completion

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ _fancygit() {
2525
--disable-double-line \
2626
--enable-rich-notification \
2727
--disable-rich-notification \
28+
--enable-bold-prompt \
29+
--disable-bold-prompt \
2830
--set-user-name \
2931
--unset-user-name \
3032
--set-host-name \

help.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ FEATURE SWITCHER COMMANDS:
3333
fancygit --disable-double-line Show a single line prompt.
3434
fancygit --enable-rich-notification Show notification area with icons.
3535
fancygit --disable-rich-notification Show notification area with simple symbols.
36+
fancygit --enable-bold-prompt Show bold prompt font.
37+
fancygit --disable-bold-prompt Show regular prompt font.
3638
3739
THEME COMMANDS:
3840
fancygit --theme-default Change prompt to the default theme.

themes/default.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ fancygit_theme_builder() {
4949
local none="\\[\\e[39m\\]"
5050
local bold_none="\\[\\e[0m\\]"
5151
local bg_none="\\[\\e[49m\\]"
52+
local bold_prompt=""
53+
local normal_prompt=""
54+
55+
if fancygit_config_is "bold_prompt" "true"
56+
then
57+
bold_none=""
58+
bold_prompt="$(tput bold)"
59+
normal_prompt="$(tput sgr0)"
60+
fi
5261

5362
# Prompt style
5463
local separator
@@ -110,7 +119,7 @@ fancygit_theme_builder() {
110119
# No branch found, so we're not in a git repo.
111120
prompt_env=$(__fancygit_get_venv_icon)
112121
prompt_path="${path}${prompt_env} ${prompt_path} ${path_end}${workdir_color_tag}${separator}${none}"
113-
PS1="${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_double_line} "
122+
PS1="${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_double_line}${normal_prompt} "
114123
return
115124
fi
116125

@@ -142,7 +151,7 @@ fancygit_theme_builder() {
142151
notification_area=$(fancygit_get_notification_area "$is_rich_notification")
143152
prompt_path="${path_git}${notification_area} ${prompt_path} ${path_end}"
144153
prompt_branch="${branch} $(fancygit_git_get_branch_icon "${branch_name}") ${branch_name} ${branch_end}"
145-
PS1="${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${prompt_double_line} "
154+
PS1="${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${prompt_double_line}${normal_prompt} "
146155
}
147156

148157
# Here's where the magic happens!

themes/human.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ fancygit_theme_builder() {
5959
local venv_name
6060
local prompt_symbol
6161
local prompt_path
62+
local bold_prompt=""
63+
local normal_prompt=""
6264

6365
local user_name
6466
user_name=$(fancygit_config_get "user_name" "\\u")
@@ -104,6 +106,12 @@ fancygit_theme_builder() {
104106
prompt_user_at_host="${user}${user_name}${color_reset}${at} at ${color_reset}${host}${host_name}${color_reset}${user_at_host_end} in "
105107
fi
106108

109+
if fancygit_config_is "bold_prompt" "true"
110+
then
111+
bold_prompt="$(tput bold)"
112+
normal_prompt="$(tput sgr0)"
113+
fi
114+
107115
# If we have a branch name, it means we are in a git repo, so we need to make some changes on PS1.
108116
branch_name=$(fancygit_git_get_branch)
109117

@@ -117,11 +125,11 @@ fancygit_theme_builder() {
117125
prompt_path="${path_git}${path_sign}${path_end}"
118126
prompt_branch="${branch}${branch_name}${branch_end}"
119127
PS1="${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name} on ${prompt_branch} $(fancygit_get_notification_area "$is_rich_notification")"
120-
PS1="${PS1}${prompt_symbol}${is_double_line} "
128+
PS1="${bold_prompt}${PS1}${prompt_symbol}${is_double_line}${normal_prompt} "
121129
return
122130
fi
123131

124-
PS1="${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name} ${prompt_symbol}${is_double_line} "
132+
PS1="${bold_prompt}${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name} ${prompt_symbol}${is_double_line}${normal_prompt} "
125133
}
126134

127135
# Here's where the magic happens!

themes/simple.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ fancygit_theme_builder() {
4646
local venv_name
4747
local branch_area
4848
local where
49+
local bold_prompt=""
50+
local normal_prompt=""
51+
52+
if fancygit_config_is "bold_prompt" "true"
53+
then
54+
bold_prompt="$(tput bold)"
55+
normal_prompt="$(tput sgr0)"
56+
fi
4957

5058
# Get theme config.
5159
prompt_time="$(fancygit_theme_get_time)"
@@ -65,7 +73,7 @@ fancygit_theme_builder() {
6573
venv_name="($venv_name) "
6674
fi
6775

68-
PS1="${venv_name}${prompt_time}${user_at_host}$where\$${branch_area}${is_double_line} "
76+
PS1="${bold_prompt}${venv_name}${prompt_time}${user_at_host}$where\$${branch_area}${is_double_line}${normal_prompt} "
6977
}
7078

7179
# ----------------------------------------------------------------------------------------------------------------------

version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Author: Diogo Alexsander Cavilha <diogocavilha@gmail.com>
44
# Date: 11.17.2017
55

6-
export FANCYGIT_VERSION="7.2.0"
6+
export FANCYGIT_VERSION="7.3.0"

0 commit comments

Comments
 (0)