diff --git a/git-prompt.conf b/git-prompt.conf index e26793c..dee3c0c 100644 --- a/git-prompt.conf +++ b/git-prompt.conf @@ -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 diff --git a/git-prompt.sh b/git-prompt.sh index c819227..c908c62 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -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