File: Customizing-the-Prompt.html

package info (click to toggle)
octave3.2 3.2.4-8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 62,936 kB
  • ctags: 37,353
  • sloc: cpp: 219,497; fortran: 116,336; ansic: 10,264; sh: 5,508; makefile: 4,245; lex: 3,573; yacc: 3,062; objc: 2,042; lisp: 1,692; awk: 860; perl: 844
file content (138 lines) | stat: -rw-r--r-- 7,518 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<html lang="en">
<head>
<title>Customizing the Prompt - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<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">
<p>
<a name="Customizing-the-Prompt"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Diary-and-Echo-Commands.html#Diary-and-Echo-Commands">Diary and Echo Commands</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Customizing-readline.html#Customizing-readline">Customizing readline</a>,
Up:&nbsp;<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-134"></a><a name="index-customizing-the-prompt-135"></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>&lsquo;<samp><span class="samp">\t</span></samp>&rsquo;<dd>The time.

     <br><dt>&lsquo;<samp><span class="samp">\d</span></samp>&rsquo;<dd>The date.

     <br><dt>&lsquo;<samp><span class="samp">\n</span></samp>&rsquo;<dd>Begins a new line by printing the equivalent of a carriage return
followed by a line feed.

     <br><dt>&lsquo;<samp><span class="samp">\s</span></samp>&rsquo;<dd>The name of the program (usually just &lsquo;<samp><span class="samp">octave</span></samp>&rsquo;).

     <br><dt>&lsquo;<samp><span class="samp">\w</span></samp>&rsquo;<dd>The current working directory.

     <br><dt>&lsquo;<samp><span class="samp">\W</span></samp>&rsquo;<dd>The basename of the current working directory.

     <br><dt>&lsquo;<samp><span class="samp">\u</span></samp>&rsquo;<dd>The username of the current user.

     <br><dt>&lsquo;<samp><span class="samp">\h</span></samp>&rsquo;<dd>The hostname, up to the first `.'.

     <br><dt>&lsquo;<samp><span class="samp">\H</span></samp>&rsquo;<dd>The hostname.

     <br><dt>&lsquo;<samp><span class="samp">\#</span></samp>&rsquo;<dd>The command number of this command, counting from when Octave starts.

     <br><dt>&lsquo;<samp><span class="samp">\!</span></samp>&rsquo;<dd>The history number of this command.  This differs from &lsquo;<samp><span class="samp">\#</span></samp>&rsquo; by the
number of commands in the history list when Octave starts.

     <br><dt>&lsquo;<samp><span class="samp">\$</span></samp>&rsquo;<dd>If the effective UID is 0, a &lsquo;<samp><span class="samp">#</span></samp>&rsquo;, otherwise a &lsquo;<samp><span class="samp">$</span></samp>&rsquo;.

     <br><dt>&lsquo;<samp><span class="samp">\nnn</span></samp>&rsquo;<dd>The character whose character code in octal is <var>nnn</var>.

     <br><dt>&lsquo;<samp><span class="samp">\\</span></samp>&rsquo;<dd>A backslash. 
</dl>

<!-- input.cc -->
   <p><a name="doc_002dPS1"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>PS1</b> ()<var><a name="index-PS1-136"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>PS1</b> (<var>new_val</var>)<var><a name="index-PS1-137"></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:\#&gt; "</code>. 
To change it, use a command like

     <pre class="example">          octave:13&gt; PS1 ("\\u@\\H&gt; ")
</pre>
        <p class="noindent">which will result in the prompt &lsquo;<samp><span class="samp">boris@kremvax&gt; </span></samp>&rsquo; for the user
&lsquo;<samp><span class="samp">boris</span></samp>&rsquo; logged in on the host &lsquo;<samp><span class="samp">kremvax.kgb.su</span></samp>&rsquo;.  Note that two
backslashes are required to enter a backslash into a double-quoted
character string. 
See <a href="Strings.html#Strings">Strings</a>. 
<!-- 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>

<!-- input.cc -->
   <p><a name="doc_002dPS2"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>PS2</b> ()<var><a name="index-PS2-138"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>PS2</b> (<var>new_val</var>)<var><a name="index-PS2-139"></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>"&gt; "</code>. 
<!-- 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>

<!-- input.cc -->
   <p><a name="doc_002dPS4"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>PS4</b> ()<var><a name="index-PS4-140"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>PS4</b> (<var>new_val</var>)<var><a name="index-PS4-141"></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. 
<!-- 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>