You can also invoke a shell script inside the PS1 variable. In the example below, the ~/bin/totalfilesize.sh, which calculates the total filesize of the current directory, is invoked inside the PS1 variable.
[continue reading…]

You can also invoke a bash shell function in the PS1 as shown below.
[continue reading…]

Use the following codes and create your own personal PS1 Linux prompt that is functional and suites your taste.
[continue reading…]

You can also change color of the PS1 prompt using tput as shown below:
[continue reading…]

You can also display multiple colors in the same prompt. Add the following function to your ~/.bash_profile
[continue reading…]

Change the background color by specifying \e[{code}m in the PS1 prompt as shown below.
[continue reading…]

Display prompt in blue color, along with username, host and current directory information
[continue reading…]

You can display output of any Linux command in the prompt. The following example displays three items separated by | (pipe) in the command prompt:
[continue reading…]

In the PS1 environment variable, you can directly execute any Linux command, by specifying in the format $(linux_command). In the following example, the command $(date) is executed to display the current time inside the prompt.
[continue reading…]

The PS1 in this example displays following three information in the prompt:

  • \u – Username
  • \h – Hostname
  • \W – Base name of the current working directory

[continue reading…]