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 == | ||
C'est suite à la lecture de [http://blog.nicolargo.com/2012/02/configurer-votre-prompt-bash.html cet article] que j'ai décidé moi aussi de rafraîchir mon prompt. | C'est suite à la lecture de [http://blog.nicolargo.com/2012/02/configurer-votre-prompt-bash.html cet article] que j'ai décidé moi aussi de rafraîchir mon prompt. | ||
Donc j'ai décidé de faire une petite variante, pour ma part je n'utilise pas GIT mais SVN. | Donc j'ai décidé de faire une petite variante, pour ma part je n'utilise pas GIT mais SVN. Donc je reprends le même principe mais pour SVN. | ||
== | == custom.sh == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Ligne 53 : | Ligne 31 : | ||
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 76 : | Ligne 52 : | ||
echo -e $RIGHTPROMPT | echo -e $RIGHTPROMPT | ||
} | } | ||
# Main prompt | # Main prompt | ||
PROMPT_COMMAND="prompt;$PROMPT_COMMAND" | PROMPT_COMMAND="prompt;$PROMPT_COMMAND" | ||
if [ $EUID -ne 0 ]; then | if [ $EUID -ne 0 ]; then | ||
PS1=$UserPrompt" " | PS1=$UserPrompt" " | ||
Ligne 99 : | Ligne 62 : | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category: | [[Category:SysAdmin]] |