The prompt setup was once one of the most important features of shell programs long time ago and now people barely remember that we can change the colors. lol
The way you can change the color varies depending on what shell program you are using. You can check which shell program you are using by opening a file, /etc/passwd. The line is separated by colons, :. The first column shows the ID and the last column shows which shell program the ID is using. If other shell programs are install, you can change it with a command, "chsh", but bash (Bourne-Again SHell) is good enough so I am not gonna bother.
The default prompt setting of RaspberryPi is little complicated. This setup is stored in ~/.bashrc and if you modify the file, your change will become permanent; in other words, unless you modify the file, ~/.bashrc, your prompt will go back to where it was whenever you login again.
Let's start with a simple example: "export PS1="\u@\h \t \W\$ ".
- "\u" means the user name of the current user
- "\h" means the hostname up to the first '.'
- "\t" means the current time in 24-hour HH:MM:SS format
- "\W" means the basename of the current working directory, with $HOME abbreviated with a tilde.
Now it does what I wanted; there is no blue colored characters that I cannot read. But I am also losing the fancy green colored id and hostname. So the coloring is gone.
Coloring is little more tricky. The syntax is like this:
- "EscapeCharacter + [ + color number + m" : this will change the color and the color will be applied to later characters.
- "EscapeCharacter + [ + m" : this will bring the color back to normal.
- There are two ways to type-in "EscapeCharacter": \033 or \e.
- More than one color numbers can be listed with separation mark, ";".
- Color numbers for characters are from 30 to 37: black(30), red(31), green(32), yellow(33), blue(34), magenta(35), cyan(36), white(37).
- Background colors are from 40 to 47.
- Color number 01 will make the color brighter.
I want to apply it every time I login. In order to change the prompt permanently I need to change the file, ~/.bashrc. The screenshot above shows that I commented out the original prompt setting with a mark "#" and I added a new prompt setting.
Now when I login, the prompt is changed. Also the current path name is readable. Well... It says it is time to sleep. lol
*Note that I don't type-in password nor ID. lol. You can do it with one of my previous articles.