<html lang="en"> <head> <title>Customizing the Prompt - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Command-Line-Editing.html#Command-Line-Editing" title="Command Line Editing"> <link rel="prev" href="Customizing-readline.html#Customizing-readline" title="Customizing readline"> <link rel="next" href="Diary-and-Echo-Commands.html#Diary-and-Echo-Commands" title="Diary and Echo Commands"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Customizing-the-Prompt"></a> <p> Next: <a rel="next" accesskey="n" href="Diary-and-Echo-Commands.html#Diary-and-Echo-Commands">Diary and Echo Commands</a>, Previous: <a rel="previous" accesskey="p" href="Customizing-readline.html#Customizing-readline">Customizing readline</a>, Up: <a rel="up" accesskey="u" href="Command-Line-Editing.html#Command-Line-Editing">Command Line Editing</a> <hr> </div> <h4 class="subsection">2.4.7 Customizing the Prompt</h4> <p><a name="index-prompt-customization-155"></a><a name="index-customizing-the-prompt-156"></a> The following variables are available for customizing the appearance of the command-line prompts. Octave allows the prompt to be customized by inserting a number of backslash-escaped special characters that are decoded as follows: <dl> <dt>‘<samp><span class="samp">\t</span></samp>’<dd>The time. <br><dt>‘<samp><span class="samp">\d</span></samp>’<dd>The date. <br><dt>‘<samp><span class="samp">\n</span></samp>’<dd>Begins a new line by printing the equivalent of a carriage return followed by a line feed. <br><dt>‘<samp><span class="samp">\s</span></samp>’<dd>The name of the program (usually just ‘<samp><span class="samp">octave</span></samp>’). <br><dt>‘<samp><span class="samp">\w</span></samp>’<dd>The current working directory. <br><dt>‘<samp><span class="samp">\W</span></samp>’<dd>The basename of the current working directory. <br><dt>‘<samp><span class="samp">\u</span></samp>’<dd>The username of the current user. <br><dt>‘<samp><span class="samp">\h</span></samp>’<dd>The hostname, up to the first `.'. <br><dt>‘<samp><span class="samp">\H</span></samp>’<dd>The hostname. <br><dt>‘<samp><span class="samp">\#</span></samp>’<dd>The command number of this command, counting from when Octave starts. <br><dt>‘<samp><span class="samp">\!</span></samp>’<dd>The history number of this command. This differs from ‘<samp><span class="samp">\#</span></samp>’ by the number of commands in the history list when Octave starts. <br><dt>‘<samp><span class="samp">\$</span></samp>’<dd>If the effective UID is 0, a ‘<samp><span class="samp">#</span></samp>’, otherwise a ‘<samp><span class="samp">$</span></samp>’. <br><dt>‘<samp><span class="samp">\nnn</span></samp>’<dd>The character whose character code in octal is <var>nnn</var>. <br><dt>‘<samp><span class="samp">\\</span></samp>’<dd>A backslash. </dl> <!-- PS1 src/input.cc --> <p><a name="doc_002dPS1"></a> <div class="defun"> — Built-in Function: <var>val</var> = <b>PS1</b> ()<var><a name="index-PS1-157"></a></var><br> — Built-in Function: <var>old_val</var> = <b>PS1</b> (<var>new_val</var>)<var><a name="index-PS1-158"></a></var><br> — Built-in Function: <b>PS1</b> (<var>new_val, "local"</var>)<var><a name="index-PS1-159"></a></var><br> <blockquote><p>Query or set the primary prompt string. When executing interactively, Octave displays the primary prompt when it is ready to read a command. <p>The default value of the primary prompt string is <code>"\s:\#> "</code>. To change it, use a command like <pre class="example"> PS1 ("\\u@\\H> ") </pre> <p class="noindent">which will result in the prompt ‘<samp><span class="samp">boris@kremvax> </span></samp>’ for the user ‘<samp><span class="samp">boris</span></samp>’ logged in on the host ‘<samp><span class="samp">kremvax.kgb.su</span></samp>’. Note that two backslashes are required to enter a backslash into a double-quoted character string. See <a href="Strings.html#Strings">Strings</a>. <p>You can also use ANSI escape sequences if your terminal supports them. This can be useful for coloring the prompt. For example, <pre class="example"> PS1 ("\\[\\033[01;31m\\]\\s:\\#> \\[\\033[0m\\]") </pre> <p class="noindent">will give the default Octave prompt a red coloring. <p>When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dPS2.html#doc_002dPS2">PS2</a>, <a href="doc_002dPS4.html#doc_002dPS4">PS4</a>. </p></blockquote></div> <!-- PS2 src/input.cc --> <p><a name="doc_002dPS2"></a> <div class="defun"> — Built-in Function: <var>val</var> = <b>PS2</b> ()<var><a name="index-PS2-160"></a></var><br> — Built-in Function: <var>old_val</var> = <b>PS2</b> (<var>new_val</var>)<var><a name="index-PS2-161"></a></var><br> — Built-in Function: <b>PS2</b> (<var>new_val, "local"</var>)<var><a name="index-PS2-162"></a></var><br> <blockquote><p>Query or set the secondary prompt string. The secondary prompt is printed when Octave is expecting additional input to complete a command. For example, if you are typing a <code>for</code> loop that spans several lines, Octave will print the secondary prompt at the beginning of each line after the first. The default value of the secondary prompt string is <code>"> "</code>. <p>When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dPS1.html#doc_002dPS1">PS1</a>, <a href="doc_002dPS4.html#doc_002dPS4">PS4</a>. </p></blockquote></div> <!-- PS4 src/input.cc --> <p><a name="doc_002dPS4"></a> <div class="defun"> — Built-in Function: <var>val</var> = <b>PS4</b> ()<var><a name="index-PS4-163"></a></var><br> — Built-in Function: <var>old_val</var> = <b>PS4</b> (<var>new_val</var>)<var><a name="index-PS4-164"></a></var><br> — Built-in Function: <b>PS4</b> (<var>new_val, "local"</var>)<var><a name="index-PS4-165"></a></var><br> <blockquote><p>Query or set the character string used to prefix output produced when echoing commands is enabled. The default value is <code>"+ "</code>. See <a href="Diary-and-Echo-Commands.html#Diary-and-Echo-Commands">Diary and Echo Commands</a>, for a description of echoing commands. <p>When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002decho.html#doc_002decho">echo</a>, <a href="doc_002decho_005fexecuting_005fcommands.html#doc_002decho_005fexecuting_005fcommands">echo_executing_commands</a>, <a href="doc_002dPS1.html#doc_002dPS1">PS1</a>, <a href="doc_002dPS2.html#doc_002dPS2">PS2</a>. </p></blockquote></div> </body></html>