Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fichiers_configuration
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Membres actifs
fichiers_configuration
Commits
399c89c0
Commit
399c89c0
authored
11 years ago
by
Vincent Le gallic
Browse files
Options
Downloads
Patches
Plain Diff
En fait on n'a pas besoin que cette fonction soit commentée.
parent
ccbce1e7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.bashrc
+54
-53
54 additions, 53 deletions
.bashrc
with
54 additions
and
53 deletions
.bashrc
+
54
−
53
View file @
399c89c0
...
...
@@ -37,58 +37,58 @@ fi
[
-d
~/.bash_completion.d/
]
&&
for
f
in
~/.bash_completion.d/
*
;
do
source
$f
;
done
#~#
# +-----+
#~#
# | VCS |
#~#
# +-----+
#~#
#~#
# 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.
#~#
local LBRANCH LTYPE BRANCH TYPE DIR
#~#
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}${vcs_symbols_color}(${nocolor}$LTYPE${vcs_symbols_color})-${vcs_symbols_color}[${vcs_branch_color}$LBRANCH${vcs_symbols_color}]${nocolor}"
#~#
else
#~#
VCS_info="($LTYPE)-[$LBRANCH]"
#~#
fi
#~#
VCS_size=$((${#LTYPE}+${#LBRANCH}+5))
#~#
else
#~#
VCS_info=""
#~#
VCS_size=0
#~#
fi
#~#
}
# +-----+
# | VCS |
# +-----+
# 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.
local
LBRANCH LTYPE BRANCH TYPE DIR
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
}${
vcs_symbols_color
}
(
${
nocolor
}
$LTYPE
${
vcs_symbols_color
}
)-
${
vcs_symbols_color
}
[
${
vcs_branch_color
}
$LBRANCH
${
vcs_symbols_color
}
]
${
nocolor
}
"
else
VCS_info
=
"(
$LTYPE
)-[
$LBRANCH
]"
fi
VCS_size
=
$((${#
LTYPE
}
+
${#
LBRANCH
}
+
5
))
else
VCS_info
=
""
VCS_size
=
0
fi
}
# Pour avoir le bon umask en fonction du dossier où on se trouve
...
...
@@ -165,7 +165,8 @@ function prompt_command
local pwd
ERR DATE PROMPT DIR POST_DIR
((
SAVE_COLUMNS
==
COLUMNS
))
||
gen_minus_line
#~# #dépend de la section VCS
#~# # À décommenter si on veut des infos
#~# # quand on se trouve dans un dépôt versionné
#~# get_vcs_info
pwd
=
${
PWD
/#
$HOME
/
'~'
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment