diff --git a/clean_files.txt b/clean_files.txt index c9d6cb3b..5cececcf 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -44,6 +44,7 @@ themes/brainy themes/brunton themes/command_duration.theme.bash themes/modern +themes/purity # plugins # diff --git a/themes/purity/purity.theme.bash b/themes/purity/purity.theme.bash index c60e4af3..8fc03bf3 100644 --- a/themes/purity/purity.theme.bash +++ b/themes/purity/purity.theme.bash @@ -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