-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle all unbound parameters, even colors!
- Loading branch information
1 parent
c7c447a
commit fcbe4e9
Showing
1 changed file
with
13 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
# shellcheck shell=bash | ||
# shellcheck disable=SC2034 # Expected behavior for themes. | ||
# shellcheck disable=SC2154 #TODO: fix these all. | ||
|
||
SCM_THEME_PROMPT_PREFIX="${bold_green}[ ${normal}" | ||
SCM_THEME_PROMPT_SUFFIX="${bold_green} ] " | ||
SCM_THEME_PROMPT_DIRTY=" ${red}✗" | ||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" | ||
SCM_THEME_PROMPT_PREFIX="${bold_green?}[ ${normal?}" | ||
SCM_THEME_PROMPT_SUFFIX="${bold_green?} ] " | ||
SCM_THEME_PROMPT_DIRTY=" ${red?}✗" | ||
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}✓" | ||
|
||
prompt_command() { | ||
if [ "$(whoami)" = root ]; then | ||
cursor_color="${bold_red}" | ||
user_color="${green}" | ||
function prompt_command() { | ||
local scm_prompt_info | ||
if [ "${USER:-${LOGNAME?}}" = root ]; then | ||
cursor_color="${bold_red?}" | ||
user_color="${green?}" | ||
else | ||
cursor_color="${bold_green}" | ||
user_color="${white}" | ||
cursor_color="${bold_green?}" | ||
user_color="${white?}" | ||
fi | ||
PS1="${user_color}\u${normal}@${white}\h ${bold_black}\w\n${reset_color}$(scm_prompt_info)${cursor_color}❯ ${normal}" | ||
scm_prompt_info="$(scm_prompt_info)" | ||
PS1="${user_color}\u${normal?}@${white?}\h ${bold_black?}\w\n${reset_color?}${scm_prompt_info}${cursor_color}❯ ${normal?}" | ||
} | ||
|
||
safe_append_prompt_command prompt_command |