X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=.bashrc;h=225aa9ab826fa93980abc61b4804d8bfc874317c;hb=d4d4c5ee4cd401a8ae930560c17fed09fcfa1464;hp=c87bb95915ab77c42d9e3ca09f987261626cf46f;hpb=b3dd5193e1920d31d2c4039c4fb84baed6822d38;p=config-20-100.git diff --git a/.bashrc b/.bashrc index c87bb95..225aa9a 100644 --- a/.bashrc +++ b/.bashrc @@ -79,7 +79,7 @@ get_vcs_info () { LBRANCH=$(eval "${BRANCH[$DIR]}") LTYPE="${TYPE[$DIR]}" if [ "$color_prompt" = yes ]; then - VCS_info="${nocolor}${vcs_symbols_color}(${vcs_type_color}$LTYPE${vcs_symbols_color})-${vcs_symbols_color}[${vcs_branch_color}$LBRANCH${vcs_symbols_color}]${nocolor}" + VCS_info="${nocolor_prompt}${vcs_symbols_color}(${vcs_type_color}$LTYPE${vcs_symbols_color})-${vcs_symbols_color}[${vcs_branch_color}$LBRANCH${vcs_symbols_color}]${nocolor_prompt}" else VCS_info="($LTYPE)-[$LBRANCH]" fi @@ -98,11 +98,11 @@ get_vcs_info () { # Rien de spécial n'arrivera si vous n'avez pas le fichier .umaskrc function cd { builtin cd "$@" + ret=$? if [ -f ~/.umaskrc ]; then - umask $(/usr/bin/awk 'BEGIN {pwd=ENVIRON["PWD"]; a=length(pwd); cmax=0} {if($1==pwd) {MASK=$2;exit}; c=length($1); if(c>a) {next}; if(substr(pwd,0,c)==$1 && c > cmax) {cmax=c; MASK=$2}} END {print MASK}' ~/.umaskrc) >/dev/null - else - return 0 + umask $(/usr/bin/awk 'BEGIN {pwd=ENVIRON["PWD"]"/"; a=length(pwd); cmax=0} {if($1==pwd) {MASK=$2;exit}; c=length($1); if(c>a) {next}; if(substr(pwd,0,c+1)==$1 && c > cmax) {cmax=c; MASK=$2}} END {print MASK}' ~/.umaskrc) >/dev/null fi + return $ret } ### Attention à ce que vous éditez dans cette section ### @@ -116,25 +116,34 @@ function cd { # les couleurs doivent être entourés de \[ et \] pour délimiter les caractères # invisibles cyan='\e[1;36m' +cyan_thin='\e[0;36m' violet='\e[1;35m' violet_thin='\e[0;35m' jaune='\e[1;33m' jaune_thin='\e[0;33m' rouge='\e[1;31m' +rouge_thin='\e[0;31m' vert='\e[1;32m' vert_thin='\e[0;32m' bleu='\e[1;34m' +bleu_thin='\e[0;34m' blanc='\e[1;37m' +blanc_thin='\e[0;37m' nocolor='\e[0m' cyan_prompt="\[${cyan}\]" +cyan_thin_prompt="\[${cyan_thin}\]" violet_prompt="\[${violet}\]" violet_thin_prompt="\[${violet_thin}\]" jaune_prompt="\[${jaune}\]" jaune_thin_prompt="\[${jaune_thin}\]" rouge_prompt="\[${rouge}\]" +rouge_thin_prompt="\[${rouge_thin}\]" vert_prompt="\[${vert}\]" vert_thin_prompt="\[${vert_thin}\]" bleu_prompt="\[${bleu}\]" +bleu_thin_prompt="\[${bleu_thin}\]" +blanc_prompt="\[${blanc}\]" +blanc_thin_prompt="\[${blanc_thin}\]" nocolor_prompt="\[${nocolor}\]" if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then @@ -162,6 +171,11 @@ else color_prompt=no fi +# Est-ce qu'on veut que le prompt affiche les information sur l'éventuel dépôt +# versionné dans lequel on se trouve +#~# # Changez cette variable en "yes" pour l'afficher +display_vcs_info=no + # Génération de la ligne de "-" function gen_minus_line @@ -186,7 +200,9 @@ function prompt_command # À décommenter si on veut des infos # quand on se trouve dans un dépôt versionné - get_vcs_info + if [ "$display_vcs_info" = yes ]; then + get_vcs_info + fi pwd=${PWD/#$HOME/'~'} if (( ${#pwd} + ${VCS_size} + 27 > COLUMNS )); then @@ -208,7 +224,7 @@ function prompt_command # il faut changer $((31+($?==0)*6)) si vous y tenez vraiment et que vous comprenez ce que vous faites ERR='[ \[\e[1;$((31+($?==0)*6))m\]$?'${line_color_prompt}' ]'$MINUS_CHAR DATE="( ${date_color}\D{%H:%M:%S}${line_color_prompt} )" - PROMPT="${username_color}\u${symbols_color}@${host_color}\h ${symbols_color}\$ ${nocolor}" + PROMPT="${username_color}\u${symbols_color}@${host_color}\h ${symbols_color}\\\$ ${nocolor_prompt}" PS1=$TITLE${line_color_prompt}$MINUS_CHAR$DATE$MINUS_CHAR$DIR$MINUS_CHAR$VCS_info${line_color_prompt}$POST_DIR$ERR'\n'$PROMPT else DIR="< "$DIR" >" @@ -233,26 +249,25 @@ PROMPT_COMMAND=prompt_command # | Messages au début | # +-------------------+ -if [[ $(uname) == Linux && ( $(locale charmap) == UTF-8 && $TERM != screen ) ]]; then - MINUS_CHAR=─ - gen_minus_line - date=$(/bin/date +"%R, %A %d %B %Y") - redate=${date//é/e} - redate=${redate//û/u} - if [ "$color_prompt" = yes ]; then - echo -e "${line_color}┬─${redate//?/─}─┬${MINUS_LINE:${#date}-18}\n\ -│ ${announce_date_color}$date ${line_color}│\n\ -└─${redate//?/─}─┘\e[0m\n" +function welcome_message () +{ + if [[ $(uname) == Linux && ( $(locale charmap) == UTF-8 && $TERM != screen ) ]]; then + MINUS_CHAR=─ + gen_minus_line + date=$(/bin/date +"%R, %A %d %B %Y") + redate=${date//é/e} + redate=${redate//û/u} + if [ "$color_prompt" = yes ]; then + echo -e "${line_color}┬─${redate//?/─}─┬${MINUS_LINE:${#date}-19}\n│ ${announce_date_color}$date ${line_color}│\n└─${redate//?/─}─┘\e[0m\n" + else + echo -e "┬─${redate//?/─}──┬${MINUS_LINE:${#date}-18}\n│ $date │\n└─${redate//?/─}──┘\n" + fi + unset date else - echo -e "┬─${redate//?/─}──┬${MINUS_LINE:${#date}-18}\n\ -│ $date │\n\ -└─${redate//?/─}──┘\n" + MINUS_CHAR=- + gen_minus_line fi - unset date -else - MINUS_CHAR=- - gen_minus_line -fi +} ### ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ### ### Attention à ce que vous avez édité dans cette section ### @@ -306,3 +321,6 @@ if [ -f ~/.bash_aliases_local ]; then . ~/.bash_aliases_local fi +# On n'exécute le welcome_message que à ce moment, parce que la customisation +# local a pu changer des couleurs +welcome_message