File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -587,3 +587,14 @@ function _save-and-reload-history() {
587587 local autosave=${1:- 0}
588588 [[ $autosave -eq 1 ]] && history -a && history -c && history -r
589589}
590+
591+ function venv_prompt() {
592+ local python_venv=" "
593+ if [[ -n " ${CONDA_DEFAULT_ENV:- } " ]]; then
594+ python_venv=" ${CONDA_DEFAULT_ENV} "
595+ PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR}
596+ elif [[ -n " ${VIRTUAL_ENV:- } " ]]; then
597+ python_venv=" ${VIRTUAL_ENV##*/ } "
598+ fi
599+ [[ -n " ${python_venv} " ]] && echo " ${PYTHON_VENV_CHAR}${python_venv} "
600+ }
Original file line number Diff line number Diff line change @@ -18,19 +18,16 @@ function git_prompt_info() {
1818 echo -e " $SCM_PREFIX ${bold_red} $SCM_BRANCH$SCM_STATE$SCM_SUFFIX "
1919}
2020
21- function venv_prompt() {
22- python_venv=" "
23- # Detect python venv
24- if [[ -n " ${CONDA_DEFAULT_ENV} " ]]; then
25- python_venv=" ($PYTHON_VENV_CHAR ${CONDA_DEFAULT_ENV} ) "
26- elif [[ -n " ${VIRTUAL_ENV} " ]]; then
27- python_venv=" ($PYTHON_VENV_CHAR $( basename " ${VIRTUAL_ENV} " ) ) "
21+ function venv_parenthases() {
22+ if [[ $( venv_prompt) != " " ]]; then
23+ echo " ($( venv_prompt) ) "
24+ else
25+ echo " "
2826 fi
29- [[ -n " ${python_venv} " ]] && echo " ${python_venv} "
3027}
3128
3229function prompt_command() {
33- PS1=" $( venv_prompt ) ${bold_green} ➜ ${bold_cyan} \W${reset_color} $( scm_prompt_info) ${normal} "
30+ PS1=" $( venv_parenthases ) ${bold_green} ➜ ${bold_cyan} \W${reset_color} $( scm_prompt_info) ${normal} "
3431}
3532
3633PROMPT_COMMAND=prompt_command
You can’t perform that action at this time.
0 commit comments