Skip to content

Commit 95929b1

Browse files
committed
theme/brunton: SC2154
Handle all unbound parameters, even colors!
1 parent a4d807b commit 95929b1

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

themes/brunton/brunton.theme.bash

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
# shellcheck shell=bash
22
# shellcheck disable=SC2034 # Expected behavior for themes.
3-
# shellcheck disable=SC2154 #TODO: fix these all.
43

54
SCM_THEME_PROMPT_PREFIX=""
65
SCM_THEME_PROMPT_SUFFIX=""
76

8-
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
9-
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
10-
SCM_GIT_CHAR="${bold_green}±${normal}"
11-
SCM_SVN_CHAR="${bold_cyan}${normal}"
12-
SCM_HG_CHAR="${bold_red}${normal}"
7+
SCM_THEME_PROMPT_DIRTY=" ${bold_red?}${normal?}"
8+
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}${normal?}"
9+
SCM_GIT_CHAR="${bold_green?}±${normal?}"
10+
SCM_SVN_CHAR="${bold_cyan?}${normal?}"
11+
SCM_HG_CHAR="${bold_red?}${normal?}"
1312

14-
is_vim_shell() {
15-
if [ -n "$VIMRUNTIME" ]; then
16-
echo "[${cyan}vim shell${normal}]"
13+
function is_vim_shell() {
14+
if [[ -n "${VIMRUNTIME:-}" ]]; then
15+
echo "[${cyan?}vim shell${normal?}]"
1716
fi
1817
}
1918

20-
prompt() {
21-
SCM_PROMPT_FORMAT=' %s (%s)'
22-
PS1="${white}${background_blue} \u${normal}${background_blue}@${red}${background_blue}\h $(clock_prompt) ${reset_color}${normal} $(battery_charge)\n${bold_black}${background_white} \w ${normal}$(scm_prompt)$(is_vim_shell)\n${white}>${normal} "
19+
function prompt() {
20+
local SCM_PROMPT_FORMAT=' %s (%s)' clock_prompt battery_charge scm_prompt is_vim_shell
21+
clock_prompt="$(clock_prompt)"
22+
battery_charge="$(battery_charge)"
23+
scm_prompt="$(scm_prompt)"
24+
is_vim_shell="$(is_vim_shell)"
25+
PS1="${white?}${background_blue?} \u${normal?}${background_blue?}@${red?}${background_blue?}\h ${clock_prompt} ${reset_color?}${normal?} ${battery_charge}\n${bold_black?}${background_white?} \w ${normal?}${scm_prompt}${is_vim_shell}\n${white?}>${normal?} "
2326
}
2427

25-
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue$background_white"}
26-
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-" %H:%M:%S"}
28+
: "${THEME_CLOCK_COLOR:=${blue?}${background_white?}}"
29+
: "${THEME_CLOCK_FORMAT:=" %H:%M:%S"}"
2730

2831
safe_append_prompt_command prompt

0 commit comments

Comments
 (0)