The prompt

The prompt is defined in ps1.bashrc and set by calling __ps1 somewhere in the shell startup. The basic prompt is similar to that obtained by setting PS1 to \u@\h:\w\$ , ie username @ hostname : working directory $, with the addition that the hostname is printed in green (or the colour defined in PROMPT_OK_COLOUR) if the last command returned 0 or in red (or the colour defined in PROMPT_FAILED_COLOUR) if it returned something else. In the latter case the return code will be printed in brackets before the colon.

For example:

iain@oldrepublic:~$ ls nonexistent
ls: cannot access nonexistent: No such file or directory
iain@oldrepublic (2):~$

In addition the prompt may also show information on the current Git or Subversion branch if configured to do so.

When __ps1_git is 1 the status of the current Git branch will be printed in blue (or the colour defined in GIT_COLOUR) after the hostname. The code to do this is taken from the bash completion script distributed with Git.

When __ps1_svn is 1 the status of the current Subversion branch will be printed in magenta (or the colour defined in SVN_COLOUR) after the Git prompt.

Individual parts of the prompt can be shown or hidden by setting or unsetting the variables mentioned above. The prompt function can be used for this purpose. Use prompt show git and prompt hide git to show and hide the Git information. Similarly prompt show svn for Subversion. The user@host and last return code parts can also be toggled with prompt show user, which sets __ps1_user. If you make no changes to a checkout of my profile the Git and Subversion details will be hidden and the standard prompt parts shown.