summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Volnitsky <leonid@volnitsky.com>2012-07-06 10:59:37 -0700
committerLeonid Volnitsky <leonid@volnitsky.com>2012-07-06 10:59:37 -0700
commit807e54cf0dfbd5b3264aee01c414f8a860f23cba (patch)
tree01aa8c11fce0a8a56bcae2133adc389f76d09abd
parentfixed: filesnames with spaces, quotes and other special chars (diff)
parent* Print Python virtualenv: (diff)
downloadgit-prompt-807e54cf0dfbd5b3264aee01c414f8a860f23cba.tar.gz
git-prompt-807e54cf0dfbd5b3264aee01c414f8a860f23cba.tar.bz2
git-prompt-807e54cf0dfbd5b3264aee01c414f8a860f23cba.zip
Merge pull request #18 from jeanparpaillon/master
Add Python virtualenv to prompt
-rw-r--r--git-prompt.conf2
-rwxr-xr-xgit-prompt.sh15
2 files changed, 17 insertions, 0 deletions
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