]> gitweb.pimeys.fr Git - config-20-100.git/commitdiff
Extanded get_vcs_info, their are other vcs than git and darcs
authorValentin Samir <samir@crans.org>
Mon, 22 Jul 2013 14:14:27 +0000 (16:14 +0200)
committerValentin Samir <samir@crans.org>
Mon, 22 Jul 2013 14:14:27 +0000 (16:14 +0200)
.bashrc

diff --git a/.bashrc b/.bashrc
index 9017ff476323940fb0a918145df1461ba28a706e..a7ecdda3d68901b23782a575d1e22cec101e72e0 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -47,26 +47,33 @@ fi
 #~# get_vcs_info () {
 #~#     # Donne les infos sur le dépôt VCS courant.
 #~#     # priorité à git, puis darcs
-#~#     local BRANCH TYPE violet orange vert
+#~#     local LBRANCH LTYPE BRANCH TYPE violet orange vert
 #~#     violet="\[\e[35m\]"
 #~#     orange="\[\e[33m\]"
 #~#     vert="\[\e[32m\]"
 #~#     nocolor="\[\e[0m\]"
-#~#     BRANCH=$(git branch 2>/dev/null | sed -r "s/^[^*].*$//" | paste -s -d '' | sed -r "s/^[*] //")
-#~#     if [ -n "$BRANCH" ];
-#~#     then
-#~#         TYPE="git"
-#~#     else
-#~#         BRANCH=$(darcs show repo 2>/dev/null| egrep '^ *Cache' | sed 's@.*/\([^/]*\),.*@\1@')
-#~#         if [ -n "$BRANCH" ];
-#~#         then
-#~#             TYPE="darcs"
+#~#     declare -a TYPE
+#~#     declare -a BRANCH
+#~#     TYPE[0]="git"
+#~#     TYPE[1]="mercurial"
+#~#     TYPE[2]="darcs"
+#~#     TYPE[3]="svn"
+#~#     BRANCH[0]='git branch 2>/dev/null | sed -r "s/^[^*].*$//" | paste -s -d "" | sed -r "s/^[*] //"'
+#~#     BRANCH[1]='hg branch 2>/dev/null'
+#~#     BRANCH[2]="darcs show repo 2>/dev/null| egrep '^ *Cache' | sed 's@.*/\([^/]*\),.*@\1@'"
+#~#     BRANCH[3]="svn info 2>/dev/null | head -n 6 | tail -n 1"
+#~#     for i in $(seq 0 $((${#BRANCH[*]}-1))); do
+#~#         LBRANCH=$(eval "${BRANCH[$i]}")
+#~#         if [ -n "$LBRANCH" ]; then
+#~#            LTYPE="${TYPE[$i]}"
+#~#            break
 #~#         fi
-#~#     fi
-#~#     if [ -n "$TYPE" ];
+#~#     done
+#~#     if [ -n "$LTYPE" ];
 #~#     then
-#~#         VCS_info="${nocolor}${violet}(${nocolor}$TYPE${violet})-${violet}[${vert}$BRANCH${violet}]${nocolor}"
-#~#         VCS_size=$((${#TYPE}+${#BRANCH}+5))
+#~#         echo $LTYPE
+#~#         VCS_info="${nocolor}${violet}(${nocolor}$LTYPE${violet})-${violet}[${vert}$LBRANCH${violet}]${nocolor}"
+#~#         VCS_size=$((${#LTYPE}+${#LBRANCH}+5))
 #~#     else
 #~#         VCS_info=""
 #~#         VCS_size=0