@@ -13,11 +13,14 @@ PADDING=" " # use this character sequence to pad the segments around the separat
1313
1414PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:= " " }
1515POWERLINE_LEFT_SEPARATOR=" ${PADDING} "
16- POWERLINE_PROMPT=" last_status user_info cwd npm scm"
16+ POWERLINE_PROMPT=" python_virtual_env last_status user_info cwd npm scm"
1717
1818USER_INFO_SSH_CHAR=" ${PADDING} "
1919USER_INFO_PROMPT_COLOR=" C Bl"
2020
21+ VIRTUAL_ENV_PROMPT_COLOR=" M B"
22+
23+
2124NPM_PROMPT_COLOR=" Y Bl"
2225
2326SCM_GIT_CHAR=" ${PADDING} "
@@ -81,6 +84,36 @@ function __color {
8184 echo " \[\e[${mod} ;${fg} ;${bg} m\]"
8285}
8386
87+ function __powerline_python_virtual_env_prompt {
88+ local venv_path=" $VIRTUAL_ENV "
89+ local color=${VIRTUAL_ENV_PROMPT_COLOR}
90+ local venv_info=" "
91+ if [[ " $venv_path " != " " ]]; then
92+
93+ if [[ -f " venv/pyvenv.cfg" ]]; then
94+ shopt -s extglob
95+ configfile=" venv/pyvenv.cfg" # set the actual path name of your (DOS or Unix) config file
96+ while IFS=' =' read -r lhs rhs
97+ do
98+ if [[ ! $lhs =~ ^\ * # && -n $lhs ]]; then
99+ rhs= " ${rhs%% \# * } " # Del in line right comments
100+ rhs= " ${rhs%%* ( )} " # Del trailing spaces
101+ rhs= " ${rhs% \" * } " # Del opening string quotes
102+ rhs= " ${rhs# \" * } " # Del closing string quotes
103+ if [[ ! $lhs == * -* ]]; then
104+ declare $lhs =" $rhs "
105+ fi
106+ fi
107+ done < $configfile
108+ eval prompt= $prompt
109+ venv_info= " $prompt "
110+ else
111+ venv_info= $( basename ${venv_path} )
112+ fi
113+ fi
114+ [[ -n " ${venv_info} " ]] && echo " ${venv_info} |${color} "
115+ }
116+
84117function __powerline_user_info_prompt {
85118 local user_info=" "
86119 local color=${USER_INFO_PROMPT_COLOR}
0 commit comments