local -i i
# printf is for readability (it's easier to find %s)
- msg="(%s)-[%s/%s"
+ msg="(%s)${MINUS_CHAR}[%s/%s"
msg=$(printf $msg $vcs ${base/*\/} $branch)
# If there is a revnumber, print it
msg="${msg}|%s"
msg=$(printf $msg $action)
fi
- msg="${msg}]-"
+ msg="${msg}]${MINUS_CHAR}"
msgs[1]=$msg
# Same shit with colors
- msg="${nocolor_prompt}${vcs_symbols_color}(${vcs_type_color}%s${vcs_symbols_color})${vcs_sep_color}-${vcs_symbols_color}[${vcs_repo_color}%s${vcs_sep_color}/${vcs_branch_color}%s"
+ msg="${nocolor_prompt}${vcs_symbols_color}(${vcs_type_color}%s${vcs_symbols_color})${vcs_sep_color}${MINUS_CHAR}${vcs_symbols_color}[${vcs_repo_color}%s${vcs_sep_color}/${vcs_branch_color}%s"
msg=$(printf $msg $vcs ${base/*\/} $branch)
if [ ! -z ${rev} ]; then
msg="${msg}${vcs_colon_color}:${vcs_rev_color}%s"
msg="${msg}${nocolor_prompt}|${vcs_action_color}%s"
msg=$(printf $msg $action)
fi
- msg="${msg}${vcs_symbols_color}]${nocolor_prompt}-"
+ msg="${msg}${vcs_symbols_color}]${line_color_prompt}${MINUS_CHAR}"
msgs[0]=$msg
return 0
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
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
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
}
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
}
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
+ if [[ disabled[${vcss[$i]}] -eq 1 ]]; then
+ continue
+ fi
commands[${vcss[$i]}]=$(which ${vcss[$i]});
done;
found=0
for vcs in ${vcss[*]}; do
+ if [[ disabled[${vcs}] -eq 1 ]]; then
+ continue
+ fi
${vcs}_detect && found=1 && break
done
# 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
}
TITLE=''
fi
-# On regénére le prompt après chaque commande
+# On régénére le prompt après chaque commande
PROMPT_COMMAND=prompt_command
# +-------------------+