From f1992e9d328407f6abd7b8a9a1569979412ff00a Mon Sep 17 00:00:00 2001 From: Jean Parpaillon Date: Fri, 23 Sep 2011 17:49:08 +0200 Subject: [PATCH] * Print Python virtualenv: (in green, by default) --- git-prompt.conf | 2 ++ git-prompt.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+) 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 41aa587..cdc3d05 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -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} @@ -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 @@ -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} @@ -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 } @@ -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