diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/bash/controlling-the-prompt.html | |
new repository
Diffstat (limited to 'devdocs/bash/controlling-the-prompt.html')
| -rw-r--r-- | devdocs/bash/controlling-the-prompt.html | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/devdocs/bash/controlling-the-prompt.html b/devdocs/bash/controlling-the-prompt.html new file mode 100644 index 00000000..7d6cc090 --- /dev/null +++ b/devdocs/bash/controlling-the-prompt.html @@ -0,0 +1,6 @@ +<h1 class="section">Controlling the Prompt</h1> <p>Bash examines the value of the array variable <code>PROMPT_COMMAND</code> just before printing each primary prompt. If any elements in <code>PROMPT_COMMAND</code> are set and non-null, Bash executes each value, in numeric order, just as if it had been typed on the command line. </p> <p>In addition, the following table describes the special characters which can appear in the prompt variables <code>PS0</code>, <code>PS1</code>, <code>PS2</code>, and <code>PS4</code>: </p> <dl compact> <dt><span><code>\a</code></span></dt> <dd><p>A bell character. </p></dd> <dt><span><code>\d</code></span></dt> <dd><p>The date, in "Weekday Month Date" format (e.g., "Tue May 26"). </p></dd> <dt><span><code>\D{<var>format</var>}</code></span></dt> <dd><p>The <var>format</var> is passed to <code>strftime</code>(3) and the result is inserted into the prompt string; an empty <var>format</var> results in a locale-specific time representation. The braces are required. </p></dd> <dt><span><code>\e</code></span></dt> <dd><p>An escape character. </p></dd> <dt><span><code>\h</code></span></dt> <dd><p>The hostname, up to the first ‘.’. </p></dd> <dt><span><code>\H</code></span></dt> <dd><p>The hostname. </p></dd> <dt><span><code>\j</code></span></dt> <dd><p>The number of jobs currently managed by the shell. </p></dd> <dt><span><code>\l</code></span></dt> <dd><p>The basename of the shell’s terminal device name. </p></dd> <dt><span><code>\n</code></span></dt> <dd><p>A newline. </p></dd> <dt><span><code>\r</code></span></dt> <dd><p>A carriage return. </p></dd> <dt><span><code>\s</code></span></dt> <dd><p>The name of the shell, the basename of <code>$0</code> (the portion following the final slash). </p></dd> <dt><span><code>\t</code></span></dt> <dd><p>The time, in 24-hour HH:MM:SS format. </p></dd> <dt><span><code>\T</code></span></dt> <dd><p>The time, in 12-hour HH:MM:SS format. </p></dd> <dt><span><code>\@</code></span></dt> <dd><p>The time, in 12-hour am/pm format. </p></dd> <dt><span><code>\A</code></span></dt> <dd><p>The time, in 24-hour HH:MM format. </p></dd> <dt><span><code>\u</code></span></dt> <dd><p>The username of the current user. </p></dd> <dt><span><code>\v</code></span></dt> <dd><p>The version of Bash (e.g., 2.00) </p></dd> <dt><span><code>\V</code></span></dt> <dd><p>The release of Bash, version + patchlevel (e.g., 2.00.0) </p></dd> <dt><span><code>\w</code></span></dt> <dd><p>The value of the <code>PWD</code> shell variable (<code>$PWD</code>), with <code>$HOME</code> abbreviated with a tilde (uses the <code>$PROMPT_DIRTRIM</code> variable). </p></dd> <dt><span><code>\W</code></span></dt> <dd><p>The basename of <code>$PWD</code>, with <code>$HOME</code> abbreviated with a tilde. </p></dd> <dt><span><code>\!</code></span></dt> <dd><p>The history number of this command. </p></dd> <dt><span><code>\#</code></span></dt> <dd><p>The command number of this command. </p></dd> <dt><span><code>\$</code></span></dt> <dd><p>If the effective uid is 0, <code>#</code>, otherwise <code>$</code>. </p></dd> <dt><span><code>\<var>nnn</var></code></span></dt> <dd><p>The character whose ASCII code is the octal value <var>nnn</var>. </p></dd> <dt><span><code>\\</code></span></dt> <dd><p>A backslash. </p></dd> <dt><span><code>\[</code></span></dt> <dd><p>Begin a sequence of non-printing characters. This could be used to embed a terminal control sequence into the prompt. </p></dd> <dt><span><code>\]</code></span></dt> <dd><p>End a sequence of non-printing characters. </p></dd> </dl> <p>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 <a href="bash-history-facilities">Bash History Facilities</a>), while the command number is the position in the sequence of commands executed during the current shell session. </p> <p>After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject to the value of the <code>promptvars</code> shell option (see <a href="the-shopt-builtin">The Shopt Builtin</a>). This can have unwanted side effects if escaped portions of the string appear within command substitution or contain characters special to word expansion. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br>Licensed under the GNU Free Documentation License.<br> + <a href="https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html</a> + </p> +</div> |
