<![CDATA[Forum Ubuntu-fr.org / [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?id=377290 Wed, 24 Feb 2010 10:27:29 +0000 FluxBB <![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3299526#p3299526 sputnick a écrit :

Totor, c'est quoi tes caracteres d'échapement ?

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html

]]>
Wed, 24 Feb 2010 10:27:29 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3299526#p3299526
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3297877#p3297877 Je dirait meme plus simple :

printf '%*s\n' $COLUMNS "ceci est a droite"

Totor, c'est quoi tes caracteres d'échapement ?

]]>
Tue, 23 Feb 2010 15:16:05 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3297877#p3297877
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3297128#p3297128 Merci pour vos réponses.
Jo

]]>
Tue, 23 Feb 2010 08:57:06 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3297128#p3297128
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3261434#p3261434 Bonjour,
Sinon, pour aligner un texte à droite de la console :

droite="le texte à aligner à droite"
printf "\r\033[$(($(tput cols)-${#droite}))C${droite}"
]]>
Sat, 06 Feb 2010 11:56:52 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3261434#p3261434
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260588#p3260588 un sudo apt-get install zsh est bien plus rapide quand meme smile

Mais bon j'avais déjà fait la demande ici

Cela resemble a cela :

┌─→(n3o@matrix——————————————(~)
@
└─→(22:47)─>$                                              (22:47:44)

Ligne = a n3o@ avec le newPWD a la fin pour remplacer /home/n3o par ~
Ligne debut = a la date  jusqu'au $

enfin ligne de fin a l'uptime

enfin une boucle avec while qui ajoute des - afin d'avoir toute la longueur du terminal en fonction de la taille

]]>
Fri, 05 Feb 2010 21:01:02 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260588#p3260588
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260568#p3260568 sympa n3o51 ^^ je ne connaissais pas le RPROMPT

]]>
Fri, 05 Feb 2010 20:51:47 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260568#p3260568
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260543#p3260543 @ n3o51 > c'est mignon ton truc mais
meme pour moi qui connais à peu pres la syntaxe du bouzin
ça nous aide pas franchement : j'ai pas trouvé ou était défini tes lignes

]]>
Fri, 05 Feb 2010 20:45:22 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260543#p3260543
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260522#p3260522 Bonsoir

#!/bin/bash
function setPrompt()
{
VERT="\[\033[1;32m\]"
ROUGE="\[\e[31;1m\]"
JAUNE="\[\e[33;1m\]"
BLEU="\[\e[34;1m\]"
ROSE="\[\e[35;1m\]"
CYAN="\[\e[36;1m\]"
BLANC="\[\e[37;1m\]"
RESET="\[\e[0m\]"

newPWD=$(sed "s=$HOME=~=" <<< "${PWD}")

DATE=$(date +" %d/%m/%Y")
TIME=$(date +%H:%M)
#UPTIME1=$(uptime | sed 's/.*up *\([0-9: ]*\(min\|day\)*\([s]\{0,1\},[0-9: ]*\)\{0,1\}\),[0-9 ]*user.*/\1/')
UPTIME1=$(uptime | sed 's/.*up *\([0-9: ]*\(min[ ]*\|day[s]*\)*\(,[0-9: ]*\(min[ ]*\)*\)*\),[0-9 ]*user.*/\1/')

LIGNE="┌─→(${USER}@${HOSTNAME}${DATE})(${newPWD})"

MAX_COLUMNS=$((COLUMNS-1))
FILL=""
while [ ${#LIGNE} -lt ${MAX_COLUMNS} ];
do
  FILL="-${FILL}"
  LIGNE="${LIGNE} "
done

LIGNE1="${JAUNE}┌─→(${RESET}${VERT}${USER}${RESET}${JAUNE}@${RESET}${VERT}${HOSTNAME}${RESET}${VERT}${DATE}${RESET}${JAUNE})${FILL}(${RESET}${CYAN}${newPWD}${RESET}${JAUNE})"
LIGNE3_FIN="(${UPTIME1})"
LIGNE3_DEBUT="└─→(${TIME})─>"

FILL=""
while [ ${#LIGNE3_FIN} -lt ${MAX_COLUMNS} ];
do
  LIGNE3_FIN=" ${LIGNE3_FIN}"
  FILL=" ${FILL}"
done
LIGNE3_FIN="${FILL}${JAUNE}(${RESET}${CYAN}${UPTIME1}${RESET}${JAUNE})${RESET}${BLANC}"
PS1="${LIGNE1}\n@\n${LIGNE3_FIN}\r\[\033[1;32m\]${LIGNE3_DEBUT}"
}

tu enregistre le script

tu ajoute dans ton bashrc :

. ~/script/setPrompt.sh
PROMPT_COMMAND=setPrompt

le script tu le nomme setPrompt.sh et modifie le chemin pour qu'il te coresspond et amuse toi bien smile

]]>
Fri, 05 Feb 2010 20:39:25 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260522#p3260522
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260488#p3260488 nesthib a écrit :

je n'ai pas trop compris ce que tu veux faire jofab… tu peux donner un exemple ?

facil :
prompt.png

]]>
Fri, 05 Feb 2010 20:24:53 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260488#p3260488
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260458#p3260458 le PS2 c'est ce qui définit le caractère de continuation de ligne :

user@host:~$ echo '
> ← c'est celui là

le PS3 c'est celui qui est utilisé par la commande select :

user@host:~$ select choix in a b c ; do echo $choix ; break ; done
1) a
2) b
3) c
#? ← c'est le PS3

après je n'ai pas trop compris ce que tu veux faire jofab… tu peux donner un exemple ?

]]>
Fri, 05 Feb 2010 20:05:35 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260458#p3260458
<![CDATA[Réponse à : [resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3260282#p3260282 il me semble que c'est PS2 ou 3 (justement pas le 1 wink)

]]>
Fri, 05 Feb 2010 18:32:46 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3260282#p3260282
<![CDATA[[resolu]bash, comment afficher des éléments du prompt à droite ?]]> http://forum.ubuntu-fr.org/viewtopic.php?pid=3259581#p3259581 Bonjour,
  qqn sais comment faire l'equivalent de la variable RPROMPT de zsh sous bash (qui permet d'afficher des éléments du prompt à droite) ?
  Merci
Jo

edit modo : merci d'utiliser des titres plus explicites
edit jo : ok, désolé hmm

]]>
Fri, 05 Feb 2010 14:03:26 +0000 http://forum.ubuntu-fr.org/viewtopic.php?pid=3259581#p3259581