Many times, I have felt irritated with default command prompt.
It normally includes PWD (Present working Directory) path in each command.
When you are working in directories with descriptive names and depth of 6 to 10,
command prompt takes lot of screen-space. When you are dealing with long commands
which are inherently complicated, this stupid prompt causes them to overflow into another line..!!!
It is *really* annoying situation.
Finally, I decided to waste few hours for cleanup of my prompt.
It's not very complicated work. It needs editing few lines in ~/.bashrc file.
The $PS1 is the variable which controls the behavior of the prompt.
The PWD path information is undoubtedly useful and should be accessible,
but we don't need it embedded in prompt for each command.
The username, machine name and whole path is always visible on the Title bar of terminal window,
and is updated automatically with each directory change. So, lets drop this information.
I still add '\W' option, which gives the name (and not whole path) for the working directory.
It gives the context of each command without wasting lot of screen space.
Other options added are
'\t' - tells time of command execution
'\${?}' - tells the success or failure of last command. (0 represents success)
So, my $PS1 variable looks like this.
With some Google search, it was easy to figure out how to have colors.
And after adding colors, my PS1 became
Another improvement was done by modifying the root prompt in a similar way but to use RED color
which will warn user to be careful. Following will generate similar (but reddish) prompt for the root.
Here is a screenshot showing my new prompt in action !!

PWD is having depth more than 10 which can be seen from the title bar, but still the command prompt is clean.
It also includes the color switch when logged in as root.
Also, one wrong command is executed whose return status can be seen on the following prompt.
Here is the link
which will give information about other possibilities with the prompt.
The various possible color codes that can be used are given here.
Here is my ~/.bashrc file with important line highlighted.
It normally includes PWD (Present working Directory) path in each command.
When you are working in directories with descriptive names and depth of 6 to 10,
command prompt takes lot of screen-space. When you are dealing with long commands
which are inherently complicated, this stupid prompt causes them to overflow into another line..!!!
It is *really* annoying situation.
Finally, I decided to waste few hours for cleanup of my prompt.
It's not very complicated work. It needs editing few lines in ~/.bashrc file.
The $PS1 is the variable which controls the behavior of the prompt.
The PWD path information is undoubtedly useful and should be accessible,
but we don't need it embedded in prompt for each command.
The username, machine name and whole path is always visible on the Title bar of terminal window,
and is updated automatically with each directory change. So, lets drop this information.
I still add '\W' option, which gives the name (and not whole path) for the working directory.
It gives the context of each command without wasting lot of screen space.
Other options added are
'\t' - tells time of command execution
'\${?}' - tells the success or failure of last command. (0 represents success)
So, my $PS1 variable looks like this.
PS1='[\t][${?}][\W]\$ '
With some Google search, it was easy to figure out how to have colors.
And after adding colors, my PS1 became
PS1='\[\033[01;32m\][\t]\[\033[01;34m\][${?}]\[\033[01;32m\][\W]\[\033[01;34m\]\$\[\033[00m\] '
Another improvement was done by modifying the root prompt in a similar way but to use RED color
which will warn user to be careful. Following will generate similar (but reddish) prompt for the root.
PS1='\[\033[01;31m\][\t]\[\033[01;34m\][${?}]\[\033[01;32m\][\W]\[\033[01;31m\]# \[\033[00m\]'
Here is a screenshot showing my new prompt in action !!
PWD is having depth more than 10 which can be seen from the title bar, but still the command prompt is clean.
It also includes the color switch when logged in as root.
Also, one wrong command is executed whose return status can be seen on the following prompt.
Here is the link
which will give information about other possibilities with the prompt.
The various possible color codes that can be used are given here.
Here is my ~/.bashrc file with important line highlighted.
