themes/sirup: Show VirtualEnv

Added the ability to show the current Virtual Env when using Python Virtual Env.
If there's not vitual env, the theme works normal.
This commit is contained in:
Juan Swan
2023-02-12 15:36:06 +09:00
committed by Koichi Murase
parent 867d1e6336
commit 937cbbb8a5
+11 -1
View File
@@ -2,6 +2,16 @@
# For unstaged(*) and staged(+) values next to branch name in __git_ps1
GIT_PS1_SHOWDIRTYSTATE="enabled"
function omb_theme_syrup_python_venv {
local python_venv=""
if [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv=$(basename "${VIRTUAL_ENV}")
fi
[[ -n "${python_venv}" ]] && echo "[${python_venv}] "
}
function _omb_theme_sirup_rubygem {
local gemset=$(command awk -F'@' '{print $2}' <<< "$GEM_HOME")
[[ $gemset ]] && gemset="@$gemset"
@@ -15,7 +25,7 @@ function _omb_theme_sirup_rubygem {
function _omb_theme_PROMPT_COMMAND {
# Check http://github.com/Sirupsen/dotfiles for screenshot
PS1="$_omb_prompt_navy\W/$_omb_prompt_bold_navy$(_omb_theme_sirup_rubygem)$_omb_prompt_bold_green$(__git_ps1 " (%s)") ${_omb_prompt_normal}$ "
PS1="$_omb_prompt_purple$(omb_theme_syrup_python_venv)$_omb_prompt_navy\W/$_omb_prompt_bold_navy$(_omb_theme_sirup_rubygem)$_omb_prompt_bold_green$(__git_ps1 " (%s)") ${_omb_prompt_normal}$ "
}
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND