CustomizeShellPrompt

Bash does support colors in the prompt. If you used the prompt I showed earlier you know that. Now how you can do it. Place this symbol in front of the section you want to colonize. \[\033[Xm\]. Replace the "X" with the number of the color you want.Example:

PS1="\[\033[31m\][\u@\h]\[\033[0m\]>"

The translation the computer does is this: PS1="red text begin[whoami@hostname]normal display>

So basically you have told the computer all text from here to be red. After that you have told the computer to place the username and hostname in the prompt. Now return the display to a normal setting. This is important because forgetting to tell it to go back to normal means everything will be red, or worse whatever your last color command is. The point being when you are done make sure you tell it to return to normal. Okay more than one color:

PS1="\[\033[31m\][\u@\[\033[1;33m\]\h]\]\033[0m\]>"

PS1="red text[whoami@ yellow text hostname] normal display>

  • Les listes sont créées en utilisant les astérisques
    • Plus d'astérisques augmentent la profondeur de liste
      • Cette liste est terminée

Cette première ligne n'est pas une liste

  • Les listes sont créées en utilisant les astérisques
  • Plus d'astérisques augmentent la profondeur de liste
    • Cette liste est terminée

Cette première ligne n'est pas une liste


Page originale sur PmWikiFr.CustomizeShellPrompt - Référencé par
Dernières modifications:
PmWikiFr.CustomizeShellPrompt: 10 septembre 2011 à 15h40