2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2021-11-10 22:48:48 +01:00
|
|
|
|
|
|
|
OSH_THEME_GIT_PROMPT_DIRTY="✗"
|
|
|
|
OSH_THEME_GIT_PROMPT_CLEAN="✓"
|
|
|
|
|
|
|
|
# Nicely formatted terminal prompt
|
2023-02-10 00:38:56 +09:00
|
|
|
function _omb_theme_half_way_prompt_scm {
|
2021-12-30 12:05:37 +01:00
|
|
|
local CHAR=$(scm_char)
|
2021-12-30 22:01:14 +09:00
|
|
|
if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then
|
2022-01-24 14:55:36 +09:00
|
|
|
printf '%s' " on ${_omb_prompt_navy}$(git_current_branch)$(parse_git_dirty)${_omb_prompt_normal} "
|
2021-11-10 22:48:48 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-10 00:38:56 +09:00
|
|
|
function _omb_theme_PROMPT_COMMAND {
|
2022-01-24 14:55:36 +09:00
|
|
|
local ps_username="${_omb_prompt_purple}\u${_omb_prompt_normal}"
|
lib, themes: Resolve conflicting variables
"lib" has used the variables "red", "green", "yellow", "blue", and
"purple" for outputting logs to stdout/stderr. On the other hand,
"themes" has used the same variables for including escape sequences in
PS1. These two sets of variables have different values, i.e., the
latter is enclosed by '\[' and '\]' and contains escaped '\e', which
means that there have been variable conflicts. In this commit, more
specific variables are used in these places to resolve the conflicts.
2022-01-19 17:23:35 +09:00
|
|
|
local ps_path="${_omb_prompt_green}\w${_omb_prompt_normal}"
|
2022-01-24 14:55:36 +09:00
|
|
|
local ps_user_mark="${_omb_prompt_red}λ${_omb_prompt_normal}"
|
2021-11-10 22:48:48 +01:00
|
|
|
|
2021-12-30 22:01:14 +09:00
|
|
|
PS1="$ps_username in $ps_path$(_omb_theme_half_way_prompt_scm) $ps_user_mark "
|
2021-11-10 22:48:48 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 12:40:43 +09:00
|
|
|
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
|