From c7f6e80ad04758e18e9c9f97850a9b2e59faeaf1 Mon Sep 17 00:00:00 2001 From: tiago Date: Fri, 22 Jan 2021 17:07:16 +0000 Subject: [PATCH 1/4] fix modern theme, added virtualenv name --- themes/modern/modern.theme.bash | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 583764e29a..aa01234f6c 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -35,18 +35,22 @@ modern_scm_prompt() { fi } +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 + +} prompt() { - if [ $? -ne 0 ] - then - # Yes, the indenting on these is weird, but it has to be like - # this otherwise it won't display properly. + detect_venv + + PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell) +└─▪ ${python_venv}${dir_color} " - PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell) -${bold_red}└─▪${normal} " - else - PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell) -└─▪ " - fi } PS2="└─▪ " From bb6354e2056be138987fc7943ab9b74cc19caada Mon Sep 17 00:00:00 2001 From: tiago Date: Sat, 23 Jan 2021 14:42:58 +0000 Subject: [PATCH 2/4] removed trailing spaces --- themes/modern/modern.theme.bash | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index aa01234f6c..1398bba9a5 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -47,14 +47,11 @@ detect_venv() { } prompt() { detect_venv - - PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell) -└─▪ ${python_venv}${dir_color} " + + PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ ${python_venv}${dir_color} " } PS2="└─▪ " - - -safe_append_prompt_command prompt +safe_append_prompt_command prompt \ No newline at end of file From 54bf7f9a59ec64413feb63ec5fec038569d66b2a Mon Sep 17 00:00:00 2001 From: tiago Date: Sat, 23 Jan 2021 17:10:32 +0000 Subject: [PATCH 3/4] check if last command successful --- themes/modern/modern.theme.bash | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 1398bba9a5..496d61e35a 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -39,19 +39,23 @@ detect_venv() { python_venv="" # Detect python venv if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then - python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV})" + python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV}) " elif [[ -n "${VIRTUAL_ENV}" ]]; then - python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}"))" + python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) " fi - } + prompt() { + if [ $? -ne 0 ]; then + PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n${bold_red}└─▪${normal} " + else + PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ " + fi detect_venv - - PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ ${python_venv}${dir_color} " - + PS1+="${python_venv}${dir_color}" } PS2="└─▪ " -safe_append_prompt_command prompt \ No newline at end of file +safe_append_prompt_command prompt + From e2be8bc2bc9dccf2f2023c7d262b6e68ea02132a Mon Sep 17 00:00:00 2001 From: tiago Date: Sat, 23 Jan 2021 17:30:20 +0000 Subject: [PATCH 4/4] trailing and code style --- themes/modern/modern.theme.bash | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index 496d61e35a..cfc20e9a09 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -9,26 +9,24 @@ SCM_HG_CHAR="${bold_red}☿${normal}" case $TERM in xterm*) - TITLEBAR="\[\033]0;\w\007\]" - ;; + TITLEBAR="\[\033]0;\w\007\]" + ;; *) - TITLEBAR="" - ;; + TITLEBAR="" + ;; esac PS3=">> " is_vim_shell() { - if [ ! -z "$VIMRUNTIME" ] - then + if [ ! -z "$VIMRUNTIME" ]; then echo "[${cyan}vim shell${normal}]" fi } modern_scm_prompt() { CHAR=$(scm_char) - if [ $CHAR = $SCM_NONE_CHAR ] - then + if [ $CHAR = $SCM_NONE_CHAR ]; then return else echo "[$(scm_char)][$(scm_prompt_info)]" @@ -58,4 +56,3 @@ prompt() { PS2="└─▪ " safe_append_prompt_command prompt -