X-Git-Url: http://gitweb.pimeys.fr/?a=blobdiff_plain;f=.bashrc;h=409278c8378370500c078d1c8eb69966878f908d;hb=e3e196f29126a55e4f5265b0a90d539a87ea9ec2;hp=becaeb53c24a2d3290e770fb64ea016d6e9b48e8;hpb=867cc6af5aa98522886a70082557e2293a468046;p=config-20-100.git diff --git a/.bashrc b/.bashrc index becaeb5..409278c 100644 --- a/.bashrc +++ b/.bashrc @@ -44,33 +44,45 @@ fi #~# # Définition de fonction pour pouvoir afficher dans le prompt #~# # des infos quand on est dans un dépôt versionné #~# +#~# find_up () { +#~# path="$1" +#~# shift 1 +#~# while [[ "`readlink -f -- \"$path\"`" != "/" ]]; +#~# do +#~# find "$path" -maxdepth 1 -mindepth 1 "$@" +#~# path=${path}/.. +#~# done +#~# } +#~# #~# get_vcs_info () { #~# # Donne les infos sur le dépôt VCS courant. #~# # priorité à git, puis darcs -#~# local LBRANCH LTYPE BRANCH TYPE violet orange vert +#~# local LBRANCH LTYPE BRANCH TYPE DIR violet orange vert #~# violet="\[\e[35m\]" #~# orange="\[\e[33m\]" #~# vert="\[\e[32m\]" #~# nocolor="\[\e[0m\]" -#~# 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 -#~# done -#~# if [ -n "$LTYPE" ]; -#~# then +#~# declare -a DIR +#~# declare -A TYPE +#~# declare -A BRANCH +#~# DIR[0]=".git" +#~# DIR[1]=".hg" +#~# DIR[2]="_darcs" +#~# DIR[3]=".svn" +#~# TYPE[.git]="git" +#~# TYPE[.hg]="mercurial" +#~# TYPE[_darcs]="darcs" +#~# TYPE[.svn]="svn" +#~# BRANCH[.git]='git branch 2>/dev/null | sed -r "s/^[^*].*$//" | paste -s -d "" | sed -r "s/^[*] //"' +#~# BRANCH[.hg]='hg branch 2>/dev/null' +#~# BRANCH[_darcs]="darcs show repo 2>/dev/null| egrep '^ *Cache' | sed 's@.*/\([^/]*\),.*@\1@'" +#~# BRANCH[.svn]="svn info 2>/dev/null | head -n 6 | tail -n 1" +#~# +#~# DIR=$(eval "find_up \"$PWD\" -name \"\"$(printf -- ' -o -name "%s"' "${DIR[@]}") | head -n 1") +#~# if [ -n "$DIR" ]; then +#~# DIR=$(basename "$DIR") +#~# LBRANCH=$(eval "${BRANCH[$DIR]}") +#~# LTYPE="${TYPE[$DIR]}" #~# if [ "$color_prompt" = yes ]; then #~# VCS_info="${nocolor}${violet}(${nocolor}$LTYPE${violet})-${violet}[${vert}$LBRANCH${violet}]${nocolor}" #~# else @@ -83,6 +95,7 @@ fi #~# fi #~# } + # Pour avoir le bon umask en fonction du dossier où on se trouve # L'umask définit avec quel droits un fichier est créé. # Quand on écrit dans un dossier et qu'on veut que, par défaut, @@ -90,7 +103,11 @@ fi # Rien de spécial n'arrivera si vous n'avez pas le fichier .umaskrc function cd { builtin cd "$@" - [ -f ~/.umaskrc ] && 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 + 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 + fi } ### Attention à ce que vous éditez dans cette section ###