File: Commands-For-History.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 (242 lines) | stat: -rw-r--r-- 13,362 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<html lang="en">
<head>
<title>Commands For History - 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="Commands-For-Completion.html#Commands-For-Completion" title="Commands For Completion">
<link rel="next" href="Customizing-readline.html#Customizing-readline" title="Customizing readline">
<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="Commands-For-History"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Customizing-readline.html#Customizing-readline">Customizing readline</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Commands-For-Completion.html#Commands-For-Completion">Commands For Completion</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.5 Commands For Manipulating The History</h4>

<p><a name="index-command-history-113"></a><a name="index-input-history-114"></a><a name="index-history-of-commands-115"></a>
Octave normally keeps track of the commands you type so that you can
recall previous commands to edit or execute them again.  When you exit
Octave, the most recent commands you have typed, up to the number
specified by the variable <code>history_size</code>, are saved in a file. 
When Octave starts, it loads an initial list of commands from the file
named by the variable <code>history_file</code>.

   <p>Here are the commands for simple browsing and searching the history
list.

     <dl>
<dt><kbd>&lt;LFD&gt;</kbd><dt><kbd>&lt;RET&gt;</kbd><dd>Accept the current line regardless of where the cursor is.  If the line is
non-empty, add it to the history list.  If the line was a history
line, then restore the history line to its original state.

     <br><dt><kbd>C-p</kbd><dd>Move `up' through the history list.

     <br><dt><kbd>C-n</kbd><dd>Move `down' through the history list.

     <br><dt><kbd>M-&lt;</kbd><dd>Move to the first line in the history.

     <br><dt><kbd>M-&gt;</kbd><dd>Move to the end of the input history, i.e., the line you are entering!

     <br><dt><kbd>C-r</kbd><dd>Search backward starting at the current line and moving `up' through
the history as necessary.  This is an incremental search.

     <br><dt><kbd>C-s</kbd><dd>Search forward starting at the current line and moving `down' through
the history as necessary. 
</dl>

   <p>On most terminals, you can also use the up and down arrow keys in place
of <kbd>C-p</kbd> and <kbd>C-n</kbd> to move through the history list.

   <p>In addition to the keyboard commands for moving through the history
list, Octave provides three functions for viewing, editing, and
re-running chunks of commands from the history list.

<!-- oct-hist.cc -->
   <p><a name="doc_002dhistory"></a>

<div class="defun">
&mdash; Command: <b>history</b><var> options<a name="index-history-116"></a></var><br>
<blockquote><p>If invoked with no arguments, <code>history</code> displays a list of commands
that you have executed.  Valid options are:

          <dl>
<dt><code>-w </code><var>file</var><dd>Write the current history to the file <var>file</var>.  If the name is
omitted, use the default history file (normally <samp><span class="file">~/.octave_hist</span></samp>).

          <br><dt><code>-r </code><var>file</var><dd>Read the file <var>file</var>, replacing the current history list with its
contents.  If the name is omitted, use the default history file
(normally <samp><span class="file">~/.octave_hist</span></samp>).

          <br><dt><var>n</var><dd>Display only the most recent <var>n</var> lines of history.

          <br><dt><code>-q</code><dd>Don't number the displayed lines of history.  This is useful for cutting
and pasting commands using the X Window System. 
</dl>

        <p>For example, to display the five most recent commands that you have
typed without displaying line numbers, use the command
<kbd>history -q 5</kbd>. 
</p></blockquote></div>

<!-- oct-hist.cc -->
   <p><a name="doc_002dedit_005fhistory"></a>

<div class="defun">
&mdash; Command: <b>edit_history</b> [<var>first</var>] [<var>last</var>]<var><a name="index-edit_005fhistory-117"></a></var><br>
<blockquote><p>If invoked with no arguments, <code>edit_history</code> allows you to edit the
history list using the editor named by the variable <code>EDITOR</code><!-- /@w -->.  The
commands to be edited are first copied to a temporary file.  When you
exit the editor, Octave executes the commands that remain in the file. 
It is often more convenient to use <code>edit_history</code> to define functions
rather than attempting to enter them directly on the command line. 
By default, the block of commands is executed as soon as you exit the
editor.  To avoid executing any commands, simply delete all the lines
from the buffer before exiting the editor.

        <p>The <code>edit_history</code> command takes two optional arguments specifying
the history numbers of first and last commands to edit.  For example,
the command

     <pre class="example">          edit_history 13
</pre>
        <p class="noindent">extracts all the commands from the 13th through the last in the history
list.  The command

     <pre class="example">          edit_history 13 169
</pre>
        <p class="noindent">only extracts commands 13 through 169.  Specifying a larger number for
the first command than the last command reverses the list of commands
before placing them in the buffer to be edited.  If both arguments are
omitted, the previous command in the history list is used. 
<!-- 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_002drun_005fhistory.html#doc_002drun_005fhistory">run_history</a>. 
</p></blockquote></div>

<!-- oct-hist.cc -->
   <p><a name="doc_002drun_005fhistory"></a>

<div class="defun">
&mdash; Command: <b>run_history</b> [<var>first</var>] [<var>last</var>]<var><a name="index-run_005fhistory-118"></a></var><br>
<blockquote><p>Similar to <code>edit_history</code>, except that the editor is not invoked,
and the commands are simply executed as they appear in the history list. 
<!-- 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_002dedit_005fhistory.html#doc_002dedit_005fhistory">edit_history</a>. 
</p></blockquote></div>

<p class="noindent">Octave also allows you customize the details of when, where, and how history
is saved.

<!-- oct-hist.cc -->
   <p><a name="doc_002dsaving_005fhistory"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>saving_history</b> ()<var><a name="index-saving_005fhistory-119"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>saving_history</b> (<var>new_val</var>)<var><a name="index-saving_005fhistory-120"></a></var><br>
<blockquote><p>Query or set the internal variable that controls whether commands entered
on the command line are saved in the history file. 
<!-- 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_002dhistory_005ffile.html#doc_002dhistory_005ffile">history_file</a>, <a href="doc_002dhistory_005fsize.html#doc_002dhistory_005fsize">history_size</a>, <a href="doc_002dhistory_005ftimestamp_005fformat_005fstring.html#doc_002dhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>. 
</p></blockquote></div>

<!-- oct-hist.cc -->
   <p><a name="doc_002dhistory_005ffile"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>history_file</b> ()<var><a name="index-history_005ffile-121"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>history_file</b> (<var>new_val</var>)<var><a name="index-history_005ffile-122"></a></var><br>
<blockquote><p>Query or set the internal variable that specifies the name of the
file used to store command history.  The default value is
<samp><span class="file">~/.octave_hist</span></samp>, but may be overridden by the environment
variable <code>OCTAVE_HISTFILE</code><!-- /@w -->. 
<!-- 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_002dhistory_005fsize.html#doc_002dhistory_005fsize">history_size</a>, <a href="doc_002dsaving_005fhistory.html#doc_002dsaving_005fhistory">saving_history</a>, <a href="doc_002dhistory_005ftimestamp_005fformat_005fstring.html#doc_002dhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>. 
</p></blockquote></div>

<!-- oct-hist.cc -->
   <p><a name="doc_002dhistory_005fsize"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>history_size</b> ()<var><a name="index-history_005fsize-123"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>history_size</b> (<var>new_val</var>)<var><a name="index-history_005fsize-124"></a></var><br>
<blockquote><p>Query or set the internal variable that specifies how many entries
to store in the history file.  The default value is <code>1024</code>,
but may be overridden by the environment variable <code>OCTAVE_HISTSIZE</code><!-- /@w -->. 
<!-- 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_002dhistory_005ffile.html#doc_002dhistory_005ffile">history_file</a>, <a href="doc_002dhistory_005ftimestamp_005fformat_005fstring.html#doc_002dhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>, <a href="doc_002dsaving_005fhistory.html#doc_002dsaving_005fhistory">saving_history</a>. 
</p></blockquote></div>

<!-- oct-hist.cc -->
   <p><a name="doc_002dhistory_005ftimestamp_005fformat_005fstring"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>history_timestamp_format_string</b> ()<var><a name="index-history_005ftimestamp_005fformat_005fstring-125"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>history_timestamp_format_string</b> (<var>new_val</var>)<var><a name="index-history_005ftimestamp_005fformat_005fstring-126"></a></var><br>
<blockquote><p>Query or set the internal variable that specifies the format string
for the comment line that is written to the history file when Octave
exits.  The format string is passed to <code>strftime</code>.  The default
value is

     <pre class="example">          "# Octave VERSION, %a %b %d %H:%M:%S %Y %Z &lt;USER@HOST&gt;"
</pre>
        <!-- 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_002dstrftime.html#doc_002dstrftime">strftime</a>, <a href="doc_002dhistory_005ffile.html#doc_002dhistory_005ffile">history_file</a>, <a href="doc_002dhistory_005fsize.html#doc_002dhistory_005fsize">history_size</a>, <a href="doc_002dsaving_005fhistory.html#doc_002dsaving_005fhistory">saving_history</a>. 
</p></blockquote></div>

<!-- defaults.cc -->
   <p><a name="doc_002dEDITOR"></a>

<div class="defun">
&mdash; Built-in Function: <var>val</var> = <b>EDITOR</b> ()<var><a name="index-EDITOR-127"></a></var><br>
&mdash; Built-in Function: <var>old_val</var> = <b>EDITOR</b> (<var>new_val</var>)<var><a name="index-EDITOR-128"></a></var><br>
<blockquote><p>Query or set the internal variable that specifies the editor to
use with the <code>edit_history</code> command.  The default value is taken from
the environment variable <code>EDITOR</code><!-- /@w --> when Octave starts.  If the
environment variable is not initialized, <code>EDITOR</code><!-- /@w --> will be set to
<code>"emacs"</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_002dedit_005fhistory.html#doc_002dedit_005fhistory">edit_history</a>. 
</p></blockquote></div>

   </body></html>