From e3ecc9738c6501b3e4ff3e82c52215347d9f1d8f Mon Sep 17 00:00:00 2001 From: Askaiant Date: Tue, 7 Feb 2023 20:50:23 +0100 Subject: [PATCH 1/5] themes/luan: Define python venv as optional Co-authored-by: Koichi Murase --- lib/omb-prompt-base.sh | 4 ++++ templates/bashrc.osh-template | 3 +++ themes/luan/luan.theme.sh | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/omb-prompt-base.sh b/lib/omb-prompt-base.sh index 8f92e41..e5e5616 100644 --- a/lib/omb-prompt-base.sh +++ b/lib/omb-prompt-base.sh @@ -85,6 +85,8 @@ CONDAENV_THEME_PROMPT_SUFFIX='|' PYTHON_THEME_PROMPT_PREFIX=' |' PYTHON_THEME_PROMPT_SUFFIX='|' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} + ## @fn _omb_prompt_format var value fmt_prefix[:deprecated] ## @param[in] var ## @param[in] value @@ -467,6 +469,8 @@ function _omb_prompt_get_python_version { } function _omb_prompt_get_python_venv { + python_venv= + [[ ${OMB_PROMPT_SHOW_PYTHON_VENV-} == true ]] || return 1 local virtualenv condaenv _omb_prompt_get_virtualenv _omb_prompt_get_condaenv diff --git a/templates/bashrc.osh-template b/templates/bashrc.osh-template index 7cdef11..937afe5 100644 --- a/templates/bashrc.osh-template +++ b/templates/bashrc.osh-template @@ -64,6 +64,9 @@ OSH_THEME="font" # this variable. The default behavior for the empty value is "true". OMB_USE_SUDO=true +# To disable display of Python virtualenv +# OMB_PROMPT_SHOW_PYTHON_VENV=false + # Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*) # Custom completions may be added to ~/.oh-my-bash/custom/completions/ # Example format: completions=(ssh git bundler gem pip pip3) diff --git a/themes/luan/luan.theme.sh b/themes/luan/luan.theme.sh index 27a3128..a651edb 100644 --- a/themes/luan/luan.theme.sh +++ b/themes/luan/luan.theme.sh @@ -10,6 +10,9 @@ GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX="(${_omb_prompt_olive}" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_normal})" +VIRTUALENV_THEME_PROMPT_PREFIX='(' +VIRTUALENV_THEME_PROMPT_SUFFIX=') ' + RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" @@ -18,12 +21,13 @@ function _omb_theme_PROMPT_COMMAND() { user_host="${_omb_prompt_green}\u@${_omb_prompt_teal}\h${_omb_prompt_normal}" current_dir="${_omb_prompt_bold_navy}\w${_omb_prompt_normal}" rvm_ruby="${_omb_prompt_bold_brown}$(_omb_prompt_print_ruby_env)${_omb_prompt_normal}" + python_venv="$(_omb_prompt_print_python_venv)" git_branch="$(scm_prompt_info)${_omb_prompt_normal}" prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " arrow="${_omb_prompt_bold_white}▶${_omb_prompt_normal} " prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " - PS1="${dtime}${user_host}:${current_dir} ${rvm_ruby} ${git_branch} + PS1="${dtime}${python_venv}${user_host}:${current_dir} ${rvm_ruby} ${git_branch} $arrow $prompt" } From 7a54475d48fb976c173f72eb508d103030cae588 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 10 Feb 2023 12:23:13 +0900 Subject: [PATCH 2/5] themes: Specify default OMB_PROMPT_SHOW_PYTHON_VENV for each theme --- README.md | 14 ++++++++++++++ lib/omb-prompt-base.sh | 2 -- templates/bashrc.osh-template | 5 +++-- themes/cupcake/cupcake.theme.sh | 4 ++-- themes/doubletime/doubletime.theme.sh | 4 ++-- themes/font/font.theme.sh | 4 ++-- themes/garo/garo.theme.sh | 16 ++++++++-------- themes/hawaii50/hawaii50.theme.sh | 4 ++-- themes/luan/luan.theme.sh | 4 ++-- themes/pzq/pzq.theme.sh | 1 + themes/tylenol/tylenol.theme.sh | 4 ++-- 11 files changed, 38 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c5b0eef..b7ebce3 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,20 @@ If you would like to replace an existing module (theme/plugin/aliases/complet) b ### Configuration +#### Enable/disable python venv + +The python virtualenv/condaenv information in the prompt may be enabled by the following line in `~/.bashrc`. + +```bash +OMB_PROMPT_SHOW_PYTHON_VENV=true +``` + +Some themes turn on it by default. If you would like to turn it off, you may disable it by the following line in `~/.bashrc`: + +```bash +OMB_PROMPT_SHOW_PYTHON_VENV=false +``` + #### Disable internal uses of `sudo` Some plugins of oh-my-bash internally use `sudo` when it is necessary. However, this might clutter with the `sudo` log. To disable the use of `sudo` by oh-my-bash, `OMB_USE_SUDO` can be set to `false` in `~/.bashrc`. diff --git a/lib/omb-prompt-base.sh b/lib/omb-prompt-base.sh index e5e5616..7f7d310 100644 --- a/lib/omb-prompt-base.sh +++ b/lib/omb-prompt-base.sh @@ -85,8 +85,6 @@ CONDAENV_THEME_PROMPT_SUFFIX='|' PYTHON_THEME_PROMPT_PREFIX=' |' PYTHON_THEME_PROMPT_SUFFIX='|' -OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} - ## @fn _omb_prompt_format var value fmt_prefix[:deprecated] ## @param[in] var ## @param[in] value diff --git a/templates/bashrc.osh-template b/templates/bashrc.osh-template index 937afe5..b1afa8c 100644 --- a/templates/bashrc.osh-template +++ b/templates/bashrc.osh-template @@ -64,8 +64,9 @@ OSH_THEME="font" # this variable. The default behavior for the empty value is "true". OMB_USE_SUDO=true -# To disable display of Python virtualenv -# OMB_PROMPT_SHOW_PYTHON_VENV=false +# To enable/disable display of Python virtualenv and condaenv +# OMB_PROMPT_SHOW_PYTHON_VENV=true # enable +# OMB_PROMPT_SHOW_PYTHON_VENV=false # disable # Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*) # Custom completions may be added to ~/.oh-my-bash/custom/completions/ diff --git a/themes/cupcake/cupcake.theme.sh b/themes/cupcake/cupcake.theme.sh index cefaffe..97bd6eb 100644 --- a/themes/cupcake/cupcake.theme.sh +++ b/themes/cupcake/cupcake.theme.sh @@ -13,8 +13,8 @@ # virtualenv prompts VIRTUALENV_CHAR="ⓔ " -VIRTUALENV_THEME_PROMPT_PREFIX="" -VIRTUALENV_THEME_PROMPT_SUFFIX="" +OMB_PROMPT_VIRTUALENV_FORMAT='%s' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # SCM prompts SCM_NONE_CHAR="" diff --git a/themes/doubletime/doubletime.theme.sh b/themes/doubletime/doubletime.theme.sh index b318f30..d8f2801 100644 --- a/themes/doubletime/doubletime.theme.sh +++ b/themes/doubletime/doubletime.theme.sh @@ -19,8 +19,8 @@ if [ ! -z $VIRTUALENV_THEME_PROMPT_COLOR ]; then else VIRTUALENV_THEME_PROMPT_COLOR="${_omb_prompt_green}" fi -VIRTUALENV_THEME_PROMPT_PREFIX="(${VIRTUALENV_THEME_PROMPT_COLOR}py${_omb_prompt_normal}: " -VIRTUALENV_THEME_PROMPT_SUFFIX=") " +OMB_PROMPT_VIRTUALENV_FORMAT="(${VIRTUALENV_THEME_PROMPT_COLOR}py${_omb_prompt_normal}: %s) " +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`); diff --git a/themes/font/font.theme.sh b/themes/font/font.theme.sh index d5bd2c3..47ea79f 100644 --- a/themes/font/font.theme.sh +++ b/themes/font/font.theme.sh @@ -34,8 +34,8 @@ THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_bold_navy"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"} -VIRTUALENV_THEME_PROMPT_PREFIX='(' -VIRTUALENV_THEME_PROMPT_SUFFIX=') ' +OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { # This needs to be first to save last command return code diff --git a/themes/garo/garo.theme.sh b/themes/garo/garo.theme.sh index 8ebf0ad..34e8eb3 100644 --- a/themes/garo/garo.theme.sh +++ b/themes/garo/garo.theme.sh @@ -21,15 +21,15 @@ # 07:45:05 (venv) user@host ~ → # -export SCM_NONE_CHAR='' -export SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" -export SCM_THEME_PROMPT_CLEAN="" -export SCM_THEME_PROMPT_PREFIX="${_omb_prompt_green}|" -export SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" -export SCM_GIT_SHOW_MINIMAL_INFO=true +SCM_NONE_CHAR='' +SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" +SCM_THEME_PROMPT_CLEAN="" +SCM_THEME_PROMPT_PREFIX="${_omb_prompt_green}|" +SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" +SCM_GIT_SHOW_MINIMAL_INFO=true -export VIRTUALENV_THEME_PROMPT_PREFIX='(' -export VIRTUALENV_THEME_PROMPT_SUFFIX=') ' +OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { # This needs to be first to save last command return code diff --git a/themes/hawaii50/hawaii50.theme.sh b/themes/hawaii50/hawaii50.theme.sh index fe4c8bb..b89c200 100644 --- a/themes/hawaii50/hawaii50.theme.sh +++ b/themes/hawaii50/hawaii50.theme.sh @@ -66,8 +66,8 @@ RVM_THEME_PROMPT_PREFIX='' RVM_THEME_PROMPT_SUFFIX='' # virtualenv prompts -VIRTUALENV_THEME_PROMPT_PREFIX='' -VIRTUALENV_THEME_PROMPT_SUFFIX='' +OMB_PROMPT_VIRTUALENV_FORMAT='%s' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} VIRTUAL_THEME_PROMPT_PREFIX=' using ' VIRTUAL_THEME_PROMPT_SUFFIX='' diff --git a/themes/luan/luan.theme.sh b/themes/luan/luan.theme.sh index a651edb..2c4f832 100644 --- a/themes/luan/luan.theme.sh +++ b/themes/luan/luan.theme.sh @@ -10,8 +10,8 @@ GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX="(${_omb_prompt_olive}" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_normal})" -VIRTUALENV_THEME_PROMPT_PREFIX='(' -VIRTUALENV_THEME_PROMPT_SUFFIX=') ' +OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" diff --git a/themes/pzq/pzq.theme.sh b/themes/pzq/pzq.theme.sh index b9eb799..b1a3c44 100644 --- a/themes/pzq/pzq.theme.sh +++ b/themes/pzq/pzq.theme.sh @@ -8,6 +8,7 @@ OMB_PROMPT_CONDAENV_FORMAT='(%s)' OMB_PROMPT_VIRTUALENV_FORMAT='(%s)' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # ----------------------------------------------------------------- COLOR CONF D_DEFAULT_COLOR="$_omb_prompt_white" diff --git a/themes/tylenol/tylenol.theme.sh b/themes/tylenol/tylenol.theme.sh index 16e476f..26484dd 100644 --- a/themes/tylenol/tylenol.theme.sh +++ b/themes/tylenol/tylenol.theme.sh @@ -10,8 +10,8 @@ SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_olive}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" -VIRTUALENV_THEME_PROMPT_PREFIX='|' -VIRTUALENV_THEME_PROMPT_SUFFIX='|' +OMB_PROMPT_VIRTUALENV_FORMAT='|%s|' +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { PS1="\n${_omb_prompt_green}$(_omb_prompt_print_python_venv)${_omb_prompt_brown}$(_omb_prompt_print_ruby_env) ${_omb_prompt_reset_color}\h ${_omb_prompt_red}in ${_omb_prompt_reset_color}\w\n${_omb_prompt_olive}$(scm_char)$(scm_prompt_info) ${_omb_prompt_olive}→${_omb_prompt_white} " From d0ea8378a0aacf9291cdd6faf804d8d528ffee35 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 10 Feb 2023 15:15:14 +0900 Subject: [PATCH 3/5] themes/luan: Refactor the prompt codes --- themes/luan/luan.theme.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/themes/luan/luan.theme.sh b/themes/luan/luan.theme.sh index 2c4f832..50fce0a 100644 --- a/themes/luan/luan.theme.sh +++ b/themes/luan/luan.theme.sh @@ -10,24 +10,23 @@ GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX="(${_omb_prompt_olive}" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_normal})" +OMB_PROMPT_RVM_FORMAT="%s" OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} -RVM_THEME_PROMPT_PREFIX="" -RVM_THEME_PROMPT_SUFFIX="" - function _omb_theme_PROMPT_COMMAND() { - dtime="$(clock_prompt)" - user_host="${_omb_prompt_green}\u@${_omb_prompt_teal}\h${_omb_prompt_normal}" - current_dir="${_omb_prompt_bold_navy}\w${_omb_prompt_normal}" - rvm_ruby="${_omb_prompt_bold_brown}$(_omb_prompt_print_ruby_env)${_omb_prompt_normal}" - python_venv="$(_omb_prompt_print_python_venv)" - git_branch="$(scm_prompt_info)${_omb_prompt_normal}" - prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " - arrow="${_omb_prompt_bold_white}▶${_omb_prompt_normal} " - prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " + local dtime="$(clock_prompt)" + local user_host="${_omb_prompt_green}\u@${_omb_prompt_teal}\h${_omb_prompt_normal}" + local current_dir="${_omb_prompt_bold_navy}\w${_omb_prompt_normal}" + local ruby_env python_venv + _omb_prompt_get_ruby_env && ruby_env="$_omb_prompt_bold_brown$ruby_env$_omb_prompt_normal " + _omb_prompt_get_python_venv + local git_branch="$(scm_prompt_info)${_omb_prompt_normal}" + local prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " + local arrow="${_omb_prompt_bold_white}▶${_omb_prompt_normal} " + local prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " - PS1="${dtime}${python_venv}${user_host}:${current_dir} ${rvm_ruby} ${git_branch} + PS1="${dtime}${python_venv}${user_host}:${current_dir} ${ruby_env}${git_branch} $arrow $prompt" } From 0ab6594e921c579f07b3abcaf2978e3cbe0139be Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 10 Feb 2023 15:18:56 +0900 Subject: [PATCH 4/5] themes/luan: Disable the python venv by default --- themes/luan/luan.theme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/luan/luan.theme.sh b/themes/luan/luan.theme.sh index 50fce0a..5dd7430 100644 --- a/themes/luan/luan.theme.sh +++ b/themes/luan/luan.theme.sh @@ -12,7 +12,7 @@ GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_normal})" OMB_PROMPT_RVM_FORMAT="%s" OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' -OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} +OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} function _omb_theme_PROMPT_COMMAND() { local dtime="$(clock_prompt)" From 096ff01f40cd38a1b2ea67b77149643a481f4c42 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 11 Feb 2023 21:11:23 +0900 Subject: [PATCH 5/5] themes/luan: Move python_venv next to ruby_env --- themes/luan/luan.theme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/luan/luan.theme.sh b/themes/luan/luan.theme.sh index 5dd7430..455cb42 100644 --- a/themes/luan/luan.theme.sh +++ b/themes/luan/luan.theme.sh @@ -26,7 +26,7 @@ function _omb_theme_PROMPT_COMMAND() { local arrow="${_omb_prompt_bold_white}▶${_omb_prompt_normal} " local prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " - PS1="${dtime}${python_venv}${user_host}:${current_dir} ${ruby_env}${git_branch} + PS1="${dtime}${user_host}:${current_dir} ${python_venv}${ruby_env}${git_branch} $arrow $prompt" }