context factorization

This commit is contained in:
fatalerrors
2026-05-28 11:51:23 +02:00
parent a33aa5f6be
commit c13945ced5

View File

@@ -660,30 +660,18 @@ set_prompt()
_venv_env="$(_prompt_venv_env)"
_session_tags="$(_prompt_session_markers)"
if [[ -n "$_git_seg" ]]; then
_ctx="$_git_seg"
fi
if [[ -n "$_conda_env" ]]; then
if [[ -n "$_ctx" ]]; then
_ctx+=" | ${_conda_env}"
else
_ctx="${_conda_env}"
fi
fi
if [[ -n "$_venv_env" ]]; then
if [[ -n "$_ctx" ]]; then
_ctx+=" | ${_venv_env}"
else
_ctx="${_venv_env}"
fi
fi
if [[ -n "$_session_tags" ]]; then
if [[ -n "$_ctx" ]]; then
_ctx+=" | ${_session_tags}"
else
_ctx="${_session_tags}"
fi
fi
local _ctx_disp
_ctx_disp()
{
[[ -n "$1" ]] && {
[[ -n "$_ctx" ]] && _ctx+=" | $1" || _ctx="$1"
}
}
_ctx_disp "$_git_seg"
_ctx_disp "$_conda_env"
_ctx_disp "$_venv_env"
_ctx_disp "$_session_tags"
if [[ -n "$_ctx" ]]; then
PS1+="\[${_ctx_fg}${_bar_bg}\] [ ${_ctx} ]"
fi