1history(n) Tcl Built-In Commands history(n)
2
3
4
5______________________________________________________________________________
6
8 history - Manipulate the history list
9
11 history ?option? ?arg arg ...?
12______________________________________________________________________________
13
15 The history command performs one of several operations related to
16 recently-executed commands recorded in a history list. Each of these
17 recorded commands is referred to as an “event”. When specifying an
18 event to the history command, the following forms may be used:
19
20 [1] A number: if positive, it refers to the event with that number
21 (all events are numbered starting at 1). If the number is nega‐
22 tive, it selects an event relative to the current event (-1
23 refers to the previous event, -2 to the one before that, and so
24 on). Event 0 refers to the current event.
25
26 [2] A string: selects the most recent event that matches the
27 string. An event is considered to match the string either if
28 the string is the same as the first characters of the event, or
29 if the string matches the event in the sense of the string match
30 command.
31
32 The history command can take any of the following forms:
33
34 history
35 Same as history info, described below.
36
37 history add command ?exec?
38 Adds the command argument to the history list as a new event.
39 If exec is specified (or abbreviated) then the command is also
40 executed and its result is returned. If exec is not specified
41 then an empty string is returned as result.
42
43 history change newValue ?event?
44 Replaces the value recorded for an event with newValue. Event
45 specifies the event to replace, and defaults to the current
46 event (not event -1). This command is intended for use in com‐
47 mands that implement new forms of history substitution and wish
48 to replace the current event (which invokes the substitution)
49 with the command created through substitution. The return value
50 is an empty string.
51
52 history clear
53 Erase the history list. The current keep limit is retained.
54 The history event numbers are reset.
55
56 history event ?event?
57 Returns the value of the event given by event. Event defaults
58 to -1.
59
60 history info ?count?
61 Returns a formatted string (intended for humans to read) giving
62 the event number and contents for each of the events in the his‐
63 tory list except the current event. If count is specified then
64 only the most recent count events are returned.
65
66 history keep ?count?
67 This command may be used to change the size of the history list
68 to count events. Initially, 20 events are retained in the his‐
69 tory list. If count is not specified, the current keep limit is
70 returned.
71
72 history nextid
73 Returns the number of the next event to be recorded in the his‐
74 tory list. It is useful for things like printing the event num‐
75 ber in command-line prompts.
76
77 history redo ?event?
78 Re-executes the command indicated by event and returns its
79 result. Event defaults to -1. This command results in history
80 revision: see below for details.
81
83 Pre-8.0 Tcl had a complex history revision mechanism. The current
84 mechanism is more limited, and the old history operations substitute
85 and words have been removed. (As a consolation, the clear operation
86 was added.)
87
88 The history option redo results in much simpler “history revision”.
89 When this option is invoked then the most recent event is modified to
90 eliminate the history command and replace it with the result of the
91 history command. If you want to redo an event without modifying his‐
92 tory, then use the event operation to retrieve some event, and the add
93 operation to add it to history and execute it.
94
96 event, history, record
97
98
99
100Tcl history(n)