Merge pull request #1849 from tiagobarros99/purity-add-virtualenv

purity theme, added virtualenv name display
pull/1858/head
Noah Gorny 2021-03-25 19:16:35 +02:00 committed by GitHub
commit 4860fb8c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -44,6 +44,7 @@ themes/brainy
themes/brunton
themes/command_duration.theme.bash
themes/modern
themes/purity
# plugins
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
# shellcheck shell=bash
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
@ -14,9 +14,21 @@ STATUS_THEME_PROMPT_BAD="${bold_red}${reset_color}${normal} "
STATUS_THEME_PROMPT_OK="${bold_green}${reset_color}${normal} "
PURITY_THEME_PROMPT_COLOR="${PURITY_THEME_PROMPT_COLOR:=$blue}"
venv_prompt() {
python_venv=""
# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV}) "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) "
fi
[[ -n "${python_venv}" ]] && echo "${python_venv}"
}
function prompt_command() {
local ret_status="$( [ $? -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")"
PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status} "
retval=$?
local ret_status="$([ $retval -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")"
PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status}$(venv_prompt)"
}
safe_append_prompt_command prompt_command