2 @setfilename history.info
5 * History: (history). The GNU History library.
9 This file documents the GNU History library.
11 Copyright (C) 1988 Free Software Foundation, Inc.
12 Authored by Brian Fox.
14 Permission is granted to make and distribute verbatim copies of this manual
15 provided the copyright notice and this permission notice are preserved on
19 Permission is granted to process this file through Tex and print the
20 results, provided the printed document carries copying permission notice
21 identical to this one except for the removal of this paragraph (this
22 paragraph not being relevant to the printed manual).
25 Permission is granted to copy and distribute modified versions of this
26 manual under the conditions for verbatim copying, provided also that the
27 GNU Copyright statement is available to the distributee, and provided that
28 the entire resulting derived work is distributed under the terms of a
29 permission notice identical to this one.
31 Permission is granted to copy and distribute translations of this manual
32 into another language, under the above conditions for modified versions.
35 @node Top, Introduction, , (DIR)
37 This document describes the GNU History library, a programming tool that
38 provides a consistent user interface for recalling lines of previously
42 * Introduction:: What is the GNU History library for?
43 * Interactive Use:: What it feels like using History as a user.
44 * Programming:: How to use History in your programs.
47 @node Introduction, Interactive Use, , Top
48 @unnumbered Introduction
50 Many programs read input from the user a line at a time. The GNU history
51 library is able to keep track of those lines, associate arbitrary data with
52 each line, and utilize information from previous lines in making up new
55 The programmer using the History library has available to him functions for
56 remembering lines on a history stack, associating arbitrary data with a
57 line, removing lines from the stack, searching through the stack for a
58 line containing an arbitrary text string, and referencing any line on the
59 stack directly. In addition, a history @dfn{expansion} function is
60 available which provides for a consistent user interface across many
63 The end-user using programs written with the History library has the
64 benifit of a consistent user interface, with a set of well-known commands
65 for manipulating the text of previous lines and using that text in new
66 commands. The basic history manipulation commands are similar to the
67 history substitution used by Csh.
69 If the programmer desires, he can use the Readline library, which includes
70 history manipulation by default, and has the added advantage of Emacs style
73 @node Interactive Use, Programming, Introduction, Top
74 @chapter Interactive Use
76 @section History Expansion
79 The History library provides a history expansion feature that is similar to
80 the history expansion in Csh. The following text describes what syntax
81 features are available.
83 History expansion takes place in two parts. The first is to determine
84 which line from the previous history should be used during substitution.
85 The second is to select portions of that line for inclusion into the
86 current one. The line selected from the previous history is called the
87 @dfn{event}, and the portions of that line that are acted upon are called
88 @dfn{words}. The line is broken into words in the same fashion that the
89 Bash shell does, so that several English (or Unix) words surrounded by
90 quotes are considered as one word.
93 * Event Designators:: How to specify which history line to use.
94 * Word Designators:: Specifying which words are of interest.
95 * Modifiers:: Modifying the results of susbstitution.
98 @node Event Designators, Word Designators, , Interactive Use
99 @subsection Event Designators
100 @cindex event designators
102 An event designator is a reference to a command line entry in the history
108 Start a history subsititution, except when followed by a @key{SPC},
109 @key{TAB}, @key{RET}, @key{=} or @key{(}.
112 Refer to the previous command. This is a synonym for @code{!-1}.
115 Refer to command line @var{n}.
118 Refer to the current command line minus @var{n}.
121 Refer to the most recent command starting with @var{string}.
124 Refer to the most recent command containing @var{string}.
128 @node Word Designators, Modifiers, Event Designators, Interactive Use
129 @subsection Word Designators
131 A @key{:} separates the event specification from the word designator. It
132 can be omitted if the word designator begins with a @key{^}, @key{$},
133 @key{*} or @key{%}. Words are numbered from the beginning of the line,
134 with the first word being denoted by a 0 (zero).
139 The zero'th word. For many applications, this is the command word.
145 The first argument. that is, word 1.
151 The word matched by the most recent @code{?string?} search.
153 @item @var{x}-@var{y}
154 A range of words; @code{-@var{y}} is equivalent to @code{0-@var{y}}.
157 All of the words, excepting the zero'th. This is a synonym for @samp{1-$}.
158 It is not an error to use @samp{*} if there is just one word in the event.
159 The empty string is returned in that case.
163 @node Modifiers, , Word Designators, Interactive Use
164 @subsection Modifiers
166 After the optional word designator, you can add a sequence of one or more
167 of the following modifiers, each preceded by a @key{:}.
172 The entire command line typed so far. This means the current command,
173 not the previous command, so it really isn't a word designator, and doesn't
174 belong in this section.
177 Remove a trailing pathname component, leaving only the head.
180 Remove a trailing suffix of the form ".xxx", leaving the basename (root).
183 Remove all but the suffix (end).
186 Remove all leading pathname components (before the last slash), leaving
190 Print the new command but do not execute it. This takes effect
191 immediately, so it should be the last specifier on the line.
195 @node Programming, , Interactive Use, Top