Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions themes/dulcie/dulcie.theme.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
# Simplistic one-liner theme to display source control management info beside
# the ordinary Linux bash prompt.
#
# Demo:
#
# [ritola@localhost ~]$ cd .bash-it/themes/dulcie
# [ritola@localhost |master ✓| dulcie]$ # This is single line mode
# |bash-it|± master ✓|
# [ritola@localhost dulcie]$ # In multi line, the SCM info is in the separate line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were they removed? Are there problems with these descriptions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to apologize for it. No problem for these descriptions. My initial intention was to make my codes run but ignore the fact that I need to ensure I only made minimal and meaningful changes to the original codebase. I added them back in my new commit.

#
# Configuration. Change these by adding them in your .bash_profile

DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful
DULCIE_MULTILINE=${DULCIE_MULTILINE:=1} # 0 = Single line, 1 = SCM in separate line

# Configuration for Python/Conda virtual environments
OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # Keep this for consistency
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # Keep this for consistency
OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} # Keep this for consistency

This line is usually put to keep the old behavior for existing users. We haven't been showing the Python environment information in the prompt, so we should keep the default behavior to be not showing it and let the user opt-in the Python environment information by setting OMB_PROMPT_SHOW_PYTHON_VENV in ~/.bashrc explicitly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed! now the default is false.


function dulcie_color {
echo -en "\[\e[38;5;${1}m\]"
}
Expand All @@ -23,7 +19,23 @@ function dulcie_background {
echo -en "\[\e[48;5;${1}m\]"
}

function _dulcie_get_venv_name() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMB_PROMPT_SHOW_PYTHON_VENV is meant for the prompt segment generated by _omb_prompt_get_python_venv():

function _omb_prompt_get_python_venv {
python_venv=
[[ ${OMB_PROMPT_SHOW_PYTHON_VENV-} == true ]] || return 1

Please use _omb_prompt_get_python_venv instead of defining a function doing the same thing as the existing one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed! the customized function was deleted.

if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
echo "$CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" ]]; then
basename "$VIRTUAL_ENV"
fi
}

function _omb_theme_PROMPT_COMMAND {
local venv_name=$(_dulcie_get_venv_name)
local python_env_prompt=""
if [[ -n "$venv_name" ]]; then[[ "$OMB_PROMPT_SHOW_PYTHON_VENV" = true && -n "$venv_name" ]]; then
python_env_prompt="(${_omb_prompt_olive}${venv_name}${_omb_prompt_normal}) "
fi



color_user_root=$(dulcie_color 169)
color_user_nonroot="${_omb_prompt_green}"
color_host_local=$(dulcie_color 230)
Expand Down Expand Up @@ -79,18 +91,18 @@ function _omb_theme_PROMPT_COMMAND {
# Open the new terminal in the same directory
_omb_util_function_exists __vte_osc7 && __vte_osc7

PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]"
if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then
PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]"
PS1="${_omb_prompt_reset_color}[${python_env_prompt}${DULCIE_USER}@${DULCIE_HOST}${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]"
if [[ "$(scm_prompt_info)" ]]; then
SCM_THEME_PROMPT_PREFIX="${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}"
SCM_THEME_PROMPT_SUFFIX="|${_omb_prompt_normal}"
PS1="$(scm_prompt_info)\n${PS1}"
fi
else
SCM_THEME_PROMPT_PREFIX=" ${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}"
SCM_THEME_PROMPT_PREFIX=" |${DULCIE_SCM_DIR_COLOR}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. It should not be removed. I added them back

SCM_THEME_PROMPT_SUFFIX="|${_omb_prompt_normal}"
PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]"
PS1="${_omb_prompt_reset_color}[${python_env_prompt}${DULCIE_USER}@${DULCIE_HOST} ${DULCIE_WORKINGDIR}$(scm_prompt_info)]"+PS1="${_omb_prompt_reset_color}[${python_env_prompt}${DULCIE_USER}@${DULCIE_HOST}${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}$(scm_prompt_info)]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is broken.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing it out. I have fixed this code. No extra edits in addition to adding the venv info to the prompt.


fi
PS1="${PS1}${DULCIE_PROMPTCHAR} "
}
Expand Down