Skip to content

Commit

Permalink
Merge pull request lvv#18 from jeanparpaillon/master
Browse files Browse the repository at this point in the history
Add Python virtualenv to prompt
lvv committed Jul 6, 2012
2 parents a599ae8 + f1992e9 commit 807e54c
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
@@ -19,6 +19,7 @@
# svn_module=off
# hg_module=on
# vim_module=on
# virtualenv_module=on


########################################################### DEFAULT OBJECTS
@@ -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
15 changes: 15 additions & 0 deletions git-prompt.sh
Original file line number Diff line number Diff line change
@@ -22,6 +22,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}

@@ -31,6 +32,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
@@ -282,6 +284,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}

@@ -617,6 +620,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
}
@@ -667,6 +681,7 @@ prompt_command_function() {
cwd=${PWD/$HOME/\~} # substitute "~"
set_shell_label "${cwd##[/~]*/}/" # default label - path last dir

parse_virtualenv_status
parse_vcs_status

# autojump

0 comments on commit 807e54c

Please sign in to comment.