X-Git-Url: http://gitweb.pimeys.fr/?p=config-20-100.git;a=blobdiff_plain;f=.bashrc;h=c5e734700f60bcc4542681ea02c9df9489ec6405;hp=154bac0404d9828db575640b2d999d63fef1cc60;hb=760346882ebd26fcfc4192bebb1c8adf5f6221b8;hpb=b6933be1a6ea058e83f7f23cef1a15668e42e528 diff --git a/.bashrc b/.bashrc index 154bac0..c5e7347 100644 --- a/.bashrc +++ b/.bashrc @@ -92,7 +92,7 @@ vcs_formats(){ msg="${msg}${nocolor_prompt}|${vcs_action_color}%s" msg=$(printf $msg $action) fi - msg="${msg}${vcs_symbols_color}]${nocolor_prompt}${MINUS_CHAR}" + msg="${msg}${vcs_symbols_color}]${line_color_prompt}${MINUS_CHAR}" msgs[0]=$msg return 0 @@ -152,42 +152,6 @@ hg_detect(){ return $? } -# Neither is svk -# TODO - Not working : imported from zsh but not post treated -svk_detect(){ - local -a info - local -i fhash - fhash=0 - - check_command svk || return 1 - [[ -f ~/.svk/config ]] || return 1 - - # This detection function is a bit different from the others. - # We need to read svk's config file to detect a svk repository - # in the first place. Therefore, we'll just proceed and read - # the other information, too. This is more then any of the - # other detections do but this takes only one file open for - # svk at most. VCS_INFO_svk_get_data() get simpler, too. :-) - while IFS= read -r line ; do - if [[ -n ${vcs_comm[basedir]} ]] ; then - line=${line## ##} - [[ ${line} == depotpath:* ]] && vcs_comm[branch]=${line##*/} - [[ ${line} == revision:* ]] && vcs_comm[revision]=${line##*[[:space:]]##} - [[ -n ${vcs_comm[branch]} ]] && [[ -n ${vcs_comm[revision]} ]] && break - continue - fi - (( fhash > 0 )) && [[ ${line} == ' '[^[:space:]]*:* ]] && break - [[ ${line} == ' hash:'* ]] && fhash=1 && continue - (( fhash == 0 )) && continue - [[ ${PWD}/ == ${${line## ##}%:*}/* ]] && vcs_comm[basedir]=${${line## ##}%:*} - done < ~/.svk/config - - [[ -n ${vcs_comm[basedir]} ]] && \ - [[ -n ${vcs_comm[branch]} ]] && \ - [[ -n ${vcs_comm[revision]} ]] && return 0 - return 1 -} - # .svn in each directories svn_detect() { check_command svn || return 1 @@ -217,9 +181,11 @@ cvs_detect(){ darcs_detect(){ check_command darcs || return 1 - vcs_comm[detect_need_file]=format - detect_by_dir '_darcs' - return $? + # darcs diff seems a good choice since big diff is not the + # common state + darcs diff 2> /dev/null || return 1 + vcs_comm[basedir]=$(darcs show repo |awk '{if($1 == "Root:") print $2}') + return 0 } # Find git's branch @@ -348,27 +314,13 @@ hg_get_data(){ hgbase=${vcs_comm[basedir]} - file="${hgbase}/.hg/branch" - if [[ -r ${file} ]] ; then - hgbranch=$(< ${file}) - else - hgbranch='default' - fi + # Check if hg branch is efficient + hgbranch=$(hg branch) vcs_formats '' "${hgbranch}" "${hgbase}" '' return 0 } -svk_get_data(){ - local svkbranch svkbase - - svkbase=${vcs_comm[basedir]} - svkbranch=${vcs_comm[branch]} - svkrevision=${vcs_comm[revision]} - vcs_formats '' "${svkbranch}" "${svkbase}" "${svkrevision}" - return 0 -} - svn_get_data(){ local svnbase svnbranch local -a svninfo @@ -386,16 +338,15 @@ svn_get_data(){ } bzr_get_data(){ - local bzrbase bzrbr - local -a bzrinfo + local bzrbase bzrrev bzrbranch bzrinfo bzrbase=$(bzr info|awk '{if ($1 == "branch" && $2 == "root:") print $3}') - bzrbranch=$(bzr version-info|awk '{if ($1 == "branch-nick:") print $2}') - bzrrev=$(bzr version-info|awk '{if ($1 == "revno:") print $2}') bzrbase="$(vcs_realpath ${bzrbase})" - bzrbr="${bzrbranch}" + bzrinfo=$(bzr version-info|awk '{if ($1 == "branch-nick:"||$1 == "revno:") print $2}') + bzrrev=$(echo $bzrinfo|awk '{print $1}') + bzrbranch=$(echo $bzrinfo|awk '{print $2}') - vcs_formats '' "${bzrbr}" "${bzrbase}" "${bzrrev}" + vcs_formats '' "${bzrbranch}" "${bzrbase}" "${bzrrev}" return 0 } @@ -438,15 +389,25 @@ vcs_info(){ local -Ax vcs_comm commands local -x vcs local -a vcss + local -A disabled vcs="init" - vcss=(git hg bzr darcs svk svn cvs cdv) + vcss=(git hg darcs svn bzr cvs cdv) + disabled[cdv]=1 + disabled[cvs]=1 + disabled[bzr]=1 for i in $(seq 0 $(( ${#vcss[*]} - 1 ))); do - commands[${vcss[$i]}]=$(which ${vcss[$i]}); + if [[ disabled[${vcss[$i]}] -eq 1 ]]; then + continue + fi + commands[${vcss[$i]}]=$( (which ${vcss[$i]} 2>/dev/null >&2 && which ${vcss[i]})||echo true); done; found=0 for vcs in ${vcss[*]}; do + if [[ disabled[${vcs}] -eq 1 ]]; then + continue + fi ${vcs}_detect && found=1 && break done @@ -587,13 +548,13 @@ function prompt_command # Attention "\\\$" devient \$, c'est-à-dire # pour root, $ pour les autres PROMPT="${username_color}\u${symbols_color}@${host_color}\h ${symbols_color}\\\$ ${nocolor_prompt}" # On fusionne tout ça - PS1=$TITLE${line_color_prompt}$MINUS_CHAR$DATE$MINUS_CHAR$DIR$MINUS_CHAR$VCS_info${line_color_prompt}$POST_DIR$ERR'\n'$PROMPT + PS1=$TITLE${line_color_prompt}$MINUS_CHAR$DATE$MINUS_CHAR$DIR$MINUS_CHAR${line_color_prompt}$POST_DIR$VCS_info$ERR'\n'$PROMPT else DIR="< "$DIR" >" ERR='[ $? ]'$MINUS_CHAR DATE="( \D{%H:%M:%S} )" PROMPT="\u@\h \\\$ " - PS1=$TITLE$MINUS_CHAR$DATE$MINUS_CHAR$DIR$MINUS_CHAR$VCS_info$POST_DIR$ERR'\n'$PROMPT + PS1=$TITLE$MINUS_CHAR$DATE$MINUS_CHAR$DIR$MINUS_CHAR$POST_DIR$VCS_info$ERR'\n'$PROMPT fi } @@ -634,7 +595,7 @@ else TITLE='' fi -# On régénère le prompt après chaque commande +# On régénére le prompt après chaque commande PROMPT_COMMAND=prompt_command # +-------------------+