From 682d6d728d99682d8d65d94d9ff61f7cd4acd2a7 Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 10 Mar 2021 15:24:32 +0000 Subject: [PATCH 1/4] added python's virtualenv name --- themes/purity/purity.theme.bash | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/themes/purity/purity.theme.bash b/themes/purity/purity.theme.bash index c60e4af3..1d76652f 100644 --- a/themes/purity/purity.theme.bash +++ b/themes/purity/purity.theme.bash @@ -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}" +detect_venv() { + 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 +} + 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} " + PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status}" + detect_venv + PS1+="${python_venv}" } safe_append_prompt_command prompt_command From ea444459cf0e9ab73a3ce3b0a4d6fe3bfa52a756 Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 17 Mar 2021 15:26:39 +0000 Subject: [PATCH 2/4] improved PS1, function rename --- themes/purity/purity.theme.bash | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/themes/purity/purity.theme.bash b/themes/purity/purity.theme.bash index 1d76652f..96ffbdd8 100644 --- a/themes/purity/purity.theme.bash +++ b/themes/purity/purity.theme.bash @@ -14,21 +14,20 @@ 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}" -detect_venv() { +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}")) " + [[ -n "${python_venv}" ]] && echo "${python_venv}" fi } 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}" - detect_venv - PS1+="${python_venv}" + PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status}$(venv_prompt)" } safe_append_prompt_command prompt_command From 64c4c30706b6b5e9ad9fb88339c7a5269f01ccb4 Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 17 Mar 2021 15:39:57 +0000 Subject: [PATCH 3/4] minor change --- themes/purity/purity.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/purity/purity.theme.bash b/themes/purity/purity.theme.bash index 96ffbdd8..ba1b1b63 100644 --- a/themes/purity/purity.theme.bash +++ b/themes/purity/purity.theme.bash @@ -21,8 +21,8 @@ venv_prompt() { python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV}) " elif [[ -n "${VIRTUAL_ENV}" ]]; then python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) " - [[ -n "${python_venv}" ]] && echo "${python_venv}" fi + [[ -n "${python_venv}" ]] && echo "${python_venv}" } function prompt_command() { From cda81f3d74ab1822a753d704cf26f0981b8e345d Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 24 Mar 2021 21:39:57 +0000 Subject: [PATCH 4/4] cleaned and linted purity theme --- clean_files.txt | 1 + themes/purity/purity.theme.bash | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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 ba1b1b63..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}" @@ -26,8 +26,9 @@ venv_prompt() { } 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}$(venv_prompt)" + 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