home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / TERMNET / READLINE.0 / DOC / HSUSER.TEX < prev    next >
Encoding:
Text File  |  1995-04-20  |  5.9 KB  |  199 lines

  1. @ignore
  2. This file documents the user interface to the GNU History library.
  3.  
  4. Copyright (C) 1988, 1991 Free Software Foundation, Inc.
  5. Authored by Brian Fox and Chet Ramey.
  6.  
  7. Permission is granted to make and distribute verbatim copies of this manual
  8. provided the copyright notice and this permission notice are preserved on
  9. all copies.
  10.  
  11. Permission is granted to process this file through Tex and print the
  12. results, provided the printed document carries copying permission notice
  13. identical to this one except for the removal of this paragraph (this
  14. paragraph not being relevant to the printed manual).
  15.  
  16. Permission is granted to copy and distribute modified versions of this
  17. manual under the conditions for verbatim copying, provided also that the
  18. GNU Copyright statement is available to the distributee, and provided that
  19. the entire resulting derived work is distributed under the terms of a
  20. permission notice identical to this one.
  21.  
  22. Permission is granted to copy and distribute translations of this manual
  23. into another language, under the above conditions for modified versions.
  24. @end ignore
  25.  
  26. @node Using History Interactively
  27. @chapter Using History Interactively
  28.  
  29. @ifset BashFeatures
  30. This chapter describes how to use the GNU History Library interactively,
  31. from a user's standpoint.  It should be considered a user's guide.  For
  32. information on using the GNU History Library in your own programs,
  33. see the GNU Readline Library Manual.
  34. @end ifset
  35. @ifclear BashFeatures
  36. This chapter describes how to use the GNU History Library interactively,
  37. from a user's standpoint.  It should be considered a user's guide.  For
  38. information on using the GNU History Library in your own programs,
  39. @pxref{Programming with GNU History}.
  40. @end ifclear
  41.  
  42. @menu
  43. * History Interaction::        What it feels like using History as a user.
  44. @end menu
  45.  
  46. @node History Interaction
  47. @section History Interaction
  48. @cindex expansion
  49.  
  50. The History library provides a history expansion feature that is similar
  51. to the history expansion provided by @code{csh}.  The following text
  52. describes the syntax used to manipulate the history information.
  53.  
  54. History expansion takes place in two parts.  The first is to determine
  55. which line from the previous history should be used during substitution.
  56. The second is to select portions of that line for inclusion into the
  57. current one.  The line selected from the previous history is called the
  58. @dfn{event}, and the portions of that line that are acted upon are
  59. called @dfn{words}.  The line is broken into words in the same fashion
  60. that Bash does, so that several English (or Unix) words
  61. surrounded by quotes are considered as one word.
  62.  
  63. @menu
  64. * Event Designators::    How to specify which history line to use.
  65. * Word Designators::    Specifying which words are of interest.
  66. * Modifiers::        Modifying the results of substitution.
  67. @end menu
  68.  
  69. @node Event Designators
  70. @subsection Event Designators
  71. @cindex event designators
  72.  
  73. An event designator is a reference to a command line entry in the
  74. history list.
  75. @cindex history events
  76.  
  77. @table @asis
  78.  
  79. @item @code{!}
  80. Start a history substitution, except when followed by a space, tab,
  81. the end of the line, @key{=} or @key{(}.
  82.  
  83. @item @code{!!}
  84. Refer to the previous command.  This is a synonym for @code{!-1}.
  85.  
  86. @item @code{!n}
  87. Refer to command line @var{n}.
  88.  
  89. @item @code{!-n}
  90. Refer to the command @var{n} lines back.
  91.  
  92. @item @code{!string}
  93. Refer to the most recent command starting with @var{string}.
  94.  
  95. @item @code{!?string}[@code{?}]
  96. Refer to the most recent command containing @var{string}.
  97.  
  98. @item @code{!#}
  99. The entire command line typed so far.
  100.  
  101. @item @code{^string1^string2^}
  102. Quick Substitution.  Repeat the last command, replacing @var{string1}
  103. with @var{string2}.  Equivalent to
  104. @code{!!:s/string1/string2/}.
  105.  
  106. @end table
  107.  
  108. @node Word Designators
  109. @subsection Word Designators
  110.  
  111. A @key{:} separates the event specification from the word designator.  It
  112. can be omitted if the word designator begins with a @key{^}, @key{$},
  113. @key{*} or @key{%}.  Words are numbered from the beginning of the line,
  114. with the first word being denoted by a 0 (zero).
  115.  
  116. @table @code
  117.  
  118. @item 0 (zero)
  119. The @code{0}th word.  For many applications, this is the command word.
  120.  
  121. @item n
  122. The @var{n}th word.
  123.  
  124. @item ^
  125. The first argument;  that is, word 1.
  126.  
  127. @item $
  128. The last argument.
  129.  
  130. @item %
  131. The word matched by the most recent @code{?string?} search.
  132.  
  133. @item x-y
  134. A range of words; @code{-@var{y}} abbreviates @code{0-@var{y}}.
  135.  
  136. @item *
  137. All of the words, except the @code{0}th.  This is a synonym for @code{1-$}.
  138. It is not an error to use @key{*} if there is just one word in the event;
  139. the empty string is returned in that case.
  140.  
  141. @item x*
  142. Abbreviates @code{x-$}
  143.  
  144. @item x-
  145. Abbreviates @code{x-$} like @code{x*}, but omits the last word.
  146.  
  147. @end table
  148.  
  149. @node Modifiers
  150. @subsection Modifiers
  151.  
  152. After the optional word designator, you can add a sequence of one or more
  153. of the following modifiers, each preceded by a @key{:}.
  154.  
  155. @table @code
  156.  
  157. @item h
  158. Remove a trailing pathname component, leaving only the head.
  159.  
  160. @item r
  161. Remove a trailing suffix of the form @samp{.}@var{suffix}, leaving the basename.
  162.  
  163. @item e
  164. Remove all but the trailing suffix.
  165.  
  166. @item t
  167. Remove all leading  pathname  components, leaving the tail.
  168.  
  169. @item p
  170. Print the new command but do not execute it.
  171.  
  172. @ifset BashFeatures
  173. @item q
  174. Quote the substituted words, escaping further substitutions.
  175.  
  176. @item x
  177. Quote the substituted words as with @code{q},         
  178. but break into words at spaces, tabs, and newlines.
  179. @end ifset
  180.  
  181. @item s/old/new/
  182. Substitute @var{new} for the first occurrence of @var{old} in the
  183. event line.  Any delimiter may be used in place of @key{/}.
  184. The delimiter may be quoted in @var{old} and @var{new}
  185. with a single backslash.  If @key{&} appears in @var{new},
  186. it is replaced by @var{old}.  A single backslash will quote
  187. the @key{&}.  The final delimiter is optional if it is the last
  188. character on the input line.
  189.  
  190. @item &
  191. Repeat the previous substitution.
  192.  
  193. @item g
  194. Cause changes to be applied over the entire event line.  Used in
  195. conjunction with @code{s}, as in @code{gs/old/new/}, or with
  196. @code{&}.
  197.  
  198. @end table
  199.