X-Git-Url: http://gitweb.pimeys.fr/?p=config-20-100.git;a=blobdiff_plain;f=.bashrc;h=522e3f1c976e68dc210d82158a667bd873371537;hp=154bac0404d9828db575640b2d999d63fef1cc60;hb=HEAD;hpb=b6933be1a6ea058e83f7f23cef1a15668e42e528 diff --git a/.bashrc b/.bashrc index 154bac0..522e3f1 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 # +-------------------+ @@ -674,15 +635,22 @@ function welcome_message () # | Gestion de l'historique des commandes | # +---------------------------------------+ +# On spécifie explicitement le fichier d'historique. +# En effet, si on jongle entre bash et zsh, per exemple, +# comme ils n'utilisent pas le même format pour stocker le timestamp +# des commandes, on se retrouve avec des comportements non souhaités +# si on ne change pas le fichier d'historique entre les deux. +export HISTFILE=~/.bash_history + # On ne sauve pas les lignes dupliquées qui se suivent dans l'historique # ainsi que les commandes qui commencent par une espace export HISTCONTROL=ignoreboth # Nombre de lignes d'historique à garder -export HISTSIZE=5000 +export HISTSIZE="10000" # la même chose dans le fichier d'historique -export HISTFILESIZE=5000 +export HISTFILESIZE="100000" # Mémoriser le timestamp d'exécution de la commande export HISTTIMEFORMAT='%F %T - ' @@ -700,7 +668,7 @@ shopt -s histappend # Pour éviter un troll, aucune ligne de cette section n'est décommentée. # Choisissez la vôtre. -#~# export EDITOR='/usr/bin/nano' +export EDITOR='/usr/bin/nano' #~# export EDITOR='/usr/bin/vim' #~# export EDITOR='/usr/bin/emacs' #~# export EDITOR='/usr/bin/jed' @@ -708,12 +676,12 @@ shopt -s histappend # Ajouter ~/bin, /sbin et /usr/sbin à son PATH PATH=~/bin:$PATH:/sbin:/usr/sbin -#~# # Décommentez les lignes suivantes et peuplez-les correctement si -#~# # vous avez besoin de commiter en tant que root *et* que votre -#~# # /etc/sudoers contient bien la directive -#~# # Defaults env_keep += "" -#~# export GIT_AUTHOR_NAME="$(git config user.name)" -#~# export GIT_AUTHOR_EMAIL="$(git config user.email)" +# Décommentez les lignes suivantes et peuplez-les correctement si +# vous avez besoin de commiter en tant que root *et* que votre +# /etc/sudoers contient bien la directive +# Defaults env_keep += "" +export GIT_AUTHOR_NAME="$(git config user.name)" +export GIT_AUTHOR_EMAIL="$(git config user.email)" # +----------+ # | Sourcing | @@ -737,5 +705,5 @@ fi # +-----+ # On n'exécute le welcome_message que à ce moment, parce que la customisation -# local a pu changer des couleurs +# locale a pu changer des couleurs welcome_message