Skip to content

Commit f30361a

Browse files
committed
Merged with branch python-venv
1 parent fd48ce4 commit f30361a

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

theme.bash

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ PADDING=" " # use this character sequence to pad the segments around the separat
1313

1414
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
1515
POWERLINE_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

1818
USER_INFO_SSH_CHAR="${PADDING}"
1919
USER_INFO_PROMPT_COLOR="C Bl"
2020

21+
VIRTUAL_ENV_PROMPT_COLOR="M B"
22+
23+
2124
NPM_PROMPT_COLOR="Y Bl"
2225

2326
SCM_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+
84117
function __powerline_user_info_prompt {
85118
local user_info=""
86119
local color=${USER_INFO_PROMPT_COLOR}

0 commit comments

Comments
 (0)