summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Volnitsky <Leonid@Volnitsky.com>2009-05-23 17:24:10 +0300
committerLeonid Volnitsky <Leonid@Volnitsky.com>2009-05-23 17:24:10 +0300
commitdaf674375126a8f02d2f6a7f9265e87d0c14c2d8 (patch)
tree782e406f9995f71a2b6e1f26392528f2c7157a0a
parent-- renamed parse_{git,svn,ht,vcs}_dir --> parse_{...}_status; config (diff)
downloadgit-prompt-daf674375126a8f02d2f6a7f9265e87d0c14c2d8.tar.gz
git-prompt-daf674375126a8f02d2f6a7f9265e87d0c14c2d8.tar.bz2
git-prompt-daf674375126a8f02d2f6a7f9265e87d0c14c2d8.zip
-- optimization: one time processing moved to post-config
-rwxr-xr-xgit-prompt.sh24
1 files changed, 11 insertions, 13 deletions
diff --git a/git-prompt.sh b/git-prompt.sh
index 7e4b051..e3ca24d 100755
--- a/git-prompt.sh
+++ b/git-prompt.sh
@@ -49,6 +49,12 @@
##################################################################### post config
+ ################# make PARSE_VCS_STATUS
+
+ [[ $git_module = "on" ]] && type git >&/dev/null && PARSE_VCS_STATUS="parse_git_status"
+ [[ $svn_module = "on" ]] && type svn >&/dev/null && PARSE_VCS_STATUS+="||parse_svn_status"
+ [[ $hg_module = "on" ]] && type hg >&/dev/null && PARSE_VCS_STATUS+="||parse_hg_status"
+ PARSE_VCS_STATUS+="||return"
################# terminfo colors-16
#
# black? 0 8
@@ -245,9 +251,7 @@ set_shell_title() {
parse_svn_status() {
- if [[ $svn_module = "off" || ! -d .svn || $HOME == $PWD ]]; then # if home dir under svn - don't clutter home dir prompt
- return 1
- fi
+ [[ -d .svn ]] || return 1
vcs=svn
@@ -276,13 +280,8 @@ parse_svn_status() {
}
parse_hg_status() {
- if [[ $hg_module = "off" || $HOME == $PWD ]]; then
- return 1
- fi
- if [[ -z `hg branch 2> /dev/null` ]]; then
- return 1
- fi
+ [[ -d ./.hg/ ]] || return 1
vcs=hg
@@ -433,8 +432,7 @@ parse_vcs_status() {
unset status modified untracked added init detached
unset file_list modified_files untracked_files added_files
- #parse_git_status || parse_svn_status || parse_hg_status || return
- eval $PARSE_VCS_STATUS
+ eval '[[ $HOME != $PWD ]]&&' $PARSE_VCS_STATUS
### status: choose primary (for branch color)
@@ -495,8 +493,8 @@ parse_vcs_status() {
}
-trap - DEBUG #>& /dev/null
-trap '[[ $BASH_COMMAND != prompt_command_function ]] && set_shell_title $BASH_COMMAND' DEBUG #>& /dev/null
+ trap - DEBUG >& /dev/null
+ trap '[[ $BASH_COMMAND != prompt_command_function ]] && set_shell_title $BASH_COMMAND' DEBUG >& /dev/null
###################################################################### PROMPT_COMMAND