Skip to content

Commit

Permalink
* Print Python virtualenv:
Browse files Browse the repository at this point in the history
  <name> (in green, by default)
  • Loading branch information
Jean Parpaillon committed Sep 23, 2011
1 parent 24a1f3b commit f1992e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions git-prompt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# svn_module=off
# hg_module=on
# vim_module=on
# virtualenv_module=on


########################################################### DEFAULT OBJECTS
Expand Down Expand Up @@ -53,6 +54,7 @@
# if [[ -n "$cols" && $cols -ge 8 ]]; then # if terminal supports colors
# dir_color=CYAN
# rc_color=red
# virtualenv_color=green
# user_id_color=blue
# root_id_color=magenta
# else # B/W terminal
Expand Down
15 changes: 15 additions & 0 deletions git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
svn_module=${svn_module:-off}
hg_module=${hg_module:-on}
vim_module=${vim_module:-on}
virtualenv_module=${virtualenv_module:-on}
error_bell=${error_bell:-off}
cwd_cmd=${cwd_cmd:-\\w}

Expand All @@ -32,6 +33,7 @@
if [[ -n "$cols" && $cols -ge 8 ]]; then # if terminal supports colors
dir_color=${dir_color:-CYAN}
rc_color=${rc_color:-red}
virtualenv_color=${virtualenv_color:-green}
user_id_color=${user_id_color:-blue}
root_id_color=${root_id_color:-magenta}
else # only B/W
Expand Down Expand Up @@ -284,6 +286,7 @@ set_shell_label() {

dir_color=${!dir_color}
rc_color=${!rc_color}
virtualenv_color=${!virtualenv_color}
user_id_color=${!user_id_color}
root_id_color=${!root_id_color}

Expand Down Expand Up @@ -632,6 +635,17 @@ parse_vcs_status() {
#tail_local="${tail_local+$vcs_color $tail_local}${dir_color}"
}

parse_virtualenv_status() {
unset virtualenv

[[ $virtualenv_module = "on" ]] || return 1

if [[ -n "$VIRTUAL_ENV" ]] ; then
virtualenv=`basename $VIRTUAL_ENV`
rc="$rc $virtualenv_color<$virtualenv> "
fi
}

disable_set_shell_label() {
trap - DEBUG >& /dev/null
}
Expand Down Expand Up @@ -682,6 +696,7 @@ prompt_command_function() {
cwd=${PWD/$HOME/\~} # substitute "~"
set_shell_label "${cwd##[/~]*/}/" # default label - path last dir

parse_virtualenv_status
parse_vcs_status

# autojump
Expand Down

0 comments on commit f1992e9

Please sign in to comment.