Modification de Bash : Prompt avec statut SVN
La modification peut être annulée. Veuillez vérifier les différences ci-dessous pour voir si c’est bien ce que vous voulez faire, puis publier ces changements pour finaliser l’annulation de cette modification.
Version actuelle | Votre texte | ||
Ligne 1 : | Ligne 1 : | ||
== Présentation == | == Présentation == | ||
Ligne 14 : | Ligne 13 : | ||
J'en ai en plus profité pour sortir ce morceau de code du fichier .bashrc et le placer dans un endroit où il est valable pour tout le système. Il est donc situé dans /etc/profile.d/custom.sh. | J'en ai en plus profité pour sortir ce morceau de code du fichier .bashrc et le placer dans un endroit où il est valable pour tout le système. Il est donc situé dans /etc/profile.d/custom.sh. | ||
== | == custom.sh == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Ligne 53 : | Ligne 38 : | ||
RIGHTPROMPT="" | RIGHTPROMPT="" | ||
let RIGHTSIZE=0 | let RIGHTSIZE=0 | ||
SVNSTATUS=$(svn status 2>&1) | |||
echo $SVNSTATUS | grep 'not a working copy' 2>&1 >/dev/null | |||
if [ $? -eq 1 ]; then | |||
echo $SVNSTATUS | grep -P '^\s*[AMDCR]' 2>&1 >/dev/null | |||
if [ $? -eq 0 ]; then | |||
RIGHTPROMPT=$Red | |||
else | |||
RIGHTPROMPT=$Green | |||
fi | fi | ||
BRANCH=$(svn info | grep 'Repository Root' | sed -r 's|^.*/([a-z]+)$|\1|') | |||
RIGHTPROMPT=$RIGHTPROMPT"[SVN Repository $BRANCH]" | |||
let RIGHTSIZE=$(echo -n "[SVN Repository $BRANCH]" | wc -c) | |||
fi | fi | ||
Ligne 77 : | Ligne 60 : | ||
} | } | ||
# | # Main prompt | ||
if [ -z | if [ ! -z $PROMPT_COMMAND ]; then | ||
PROMPT_COMMAND="prompt;$PROMPT_COMMAND" | |||
else | |||
PROMPT_COMMAND=prompt | |||
fi | fi | ||
if [ $EUID -ne 0 ]; then | if [ $EUID -ne 0 ]; then | ||
Ligne 99 : | Ligne 74 : | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category: | [[Category:SysAdmin]] |