Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




6.9 Controlling the Prompt

The value of the variable PROMPT_COMMAND is examined just before Bash prints each primary prompt. If PROMPT_COMMAND is set and has a non-null value, then the value is executed just as if it had been typed on the command line.

In addition, the following table describes the special characters which can appear in the prompt variables:

A bell character.
The date, in "Weekday Month Date" format (e.g., "Tue May 26").
The format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required.
An escape character.
The hostname, up to the first `.'.
The hostname.
The number of jobs currently managed by the shell.
The basename of the shell's terminal device name.
A newline.
A carriage return.
The name of the shell, the basename of $0 (the portion following the final slash).
The time, in 24-hour HH:MM:SS format.
The time, in 12-hour HH:MM:SS format.
The time, in 12-hour am/pm format.
The time, in 24-hour HH:MM format.
The username of the current user.
The version of Bash (e.g., 2.00)
The release of Bash, version + patchlevel (e.g., 2.00.0)
The current working directory.
The basename of $PWD.
The history number of this command.
The command number of this command.
If the effective uid is 0, #, otherwise $.
The character whose ASCII code is the octal value nnn.
A backslash.
Begin a sequence of non-printing characters. This could be used to embed a terminal control sequence into the prompt.
End a sequence of non-printing characters.

The command number and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file (see section 9.1 Bash History Facilities), while the command number is the position in the sequence of commands executed during the current shell session.

After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject to the value of the promptvars shell option (see section 4.2 Bash Builtin Commands).

  Published under the terms of the GNU General Public License Design by Interspire