CHANGE BASH PROMPTS

Ease of customization is one of the most compelling reasons to use Linux. You can customize your GUI interface by using different window managers, desktop managers, themes, and skins. In addition, you can decide what shell you wish to use within the command-line interface--whether it's remote login, xterm, or console login.

After you select a shell, it's possible to determine how your shell prompt will look. This helps you distinguish computers, which is a useful thing when you're remotely logging in to many different machines.

Here's how a default bash prompt--the shell that a large number of people use--might look:

[joe@linux joe]$
This tells us that joe is logged in to the machine linux, and it's in a directory called joe, which is most likely his home directory. The $ character also tells us that this is a user login. (The root ordinarily shows a # character.)

A shell environment variable called PS1 controls the prompt. This variable is a string that contains certain escape sequences that get expanded to usable data. For example:

export PS1="[\u@\h \W]\$"

The \u character represents the username, \h represents the host name, and \W represents the current working directory. You can change this any way you like--you can even include ANSI escape sequences to add a little color to your prompt. To use bold whites for everything with cyan to display the full pathname, use this command:

export PS1=`echo -ne "\033[1;37m[\u@\h:\033[0;36m \w\033[1;37m]\$\033[0;37m "`

The above command will produce the following prompt (without the coloring):

[joe@linux: /home/joe]$

To make it a permanent login addition, insert the export PS1 command in your ~/.bashrc file. Remember to wrap it in backticks, because the shell needs to execute the echo command for the color to show up properly. Every time you log in, you'll be greeted with your custom colorized prompt.