From e830df50d37a67738e435ddbedf28c5b09b68806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20M=C3=BCller?= <26765321+JoernMueller@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:48:52 +0100 Subject: [PATCH] Added support for displaying the currently active Python venv --- theme.bash | 67 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/theme.bash b/theme.bash index 98ec135..64bbb80 100644 --- a/theme.bash +++ b/theme.bash @@ -7,35 +7,38 @@ # More info about color codes in https://en.wikipedia.org/wiki/ANSI_escape_code -PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} -POWERLINE_LEFT_SEPARATOR=" " -POWERLINE_PROMPT="last_status user_info cwd scm" - -USER_INFO_SSH_CHAR=" " -USER_INFO_PROMPT_COLOR="C B" - -SCM_GIT_CHAR=" " -SCM_PROMPT_CLEAN="" -SCM_PROMPT_DIRTY="*" -SCM_PROMPT_AHEAD="↑" -SCM_PROMPT_BEHIND="↓" -SCM_PROMPT_CLEAN_COLOR="G Bl" -SCM_PROMPT_DIRTY_COLOR="R Bl" -SCM_PROMPT_AHEAD_COLOR="" -SCM_PROMPT_BEHIND_COLOR="" -SCM_PROMPT_STAGED_COLOR="Y Bl" -SCM_PROMPT_UNSTAGED_COLOR="R Bl" -SCM_PROMPT_COLOR=${SCM_PROMPT_CLEAN_COLOR} - -CWD_PROMPT_COLOR="B C" - -STATUS_PROMPT_COLOR="Bl R B" -STATUS_PROMPT_ERROR="✘" -STATUS_PROMPT_ERROR_COLOR="Bl R B" -STATUS_PROMPT_ROOT="⚡" -STATUS_PROMPT_ROOT_COLOR="Bl Y B" -STATUS_PROMPT_JOBS="●" -STATUS_PROMPT_JOBS_COLOR="Bl Y B" +readonly PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} +readonly POWERLINE_LEFT_SEPARATOR=" " +readonly POWERLINE_PROMPT="last_status venv user_info cwd scm" + +readonly USER_INFO_SSH_CHAR=" " +readonly USER_INFO_PROMPT_COLOR="C B" + +readonly VENV_PROMPT_COLOR="M Y" +readonly PYTHON_SYMBOL='' + +readonly SCM_GIT_CHAR=" " +readonly SCM_PROMPT_CLEAN="" +readonly SCM_PROMPT_DIRTY="*" +readonly SCM_PROMPT_AHEAD="↑" +readonly SCM_PROMPT_BEHIND="↓" +readonly SCM_PROMPT_CLEAN_COLOR="G Bl" +readonly SCM_PROMPT_DIRTY_COLOR="R Bl" +readonly SCM_PROMPT_AHEAD_COLOR="" +readonly SCM_PROMPT_BEHIND_COLOR="" +readonly SCM_PROMPT_STAGED_COLOR="Y Bl" +readonly SCM_PROMPT_UNSTAGED_COLOR="R Bl" +readonly SCM_PROMPT_COLOR=${SCM_PROMPT_CLEAN_COLOR} + +readonly CWD_PROMPT_COLOR="B C" + +readonly STATUS_PROMPT_COLOR="Bl R B" +readonly STATUS_PROMPT_ERROR="✘" +readonly STATUS_PROMPT_ERROR_COLOR="Bl R B" +readonly STATUS_PROMPT_ROOT="⚡" +readonly STATUS_PROMPT_ROOT_COLOR="Bl Y B" +readonly STATUS_PROMPT_JOBS="●" +readonly STATUS_PROMPT_JOBS_COLOR="Bl Y B" function __color { local bg @@ -90,6 +93,12 @@ function __powerline_cwd_prompt { echo "\w|${CWD_PROMPT_COLOR}" } +function __powerline_venv_prompt { + if [ -n "${VIRTUAL_ENV}" ] ; then + echo "$PYTHON_SYMBOL($(basename $VIRTUAL_ENV))|${VENV_PROMPT_COLOR}" + fi +} + function __powerline_scm_prompt { git_local_branch="" git_branch=""