rc

[fork] interactive rc shell
git clone https://hhvn.uk/rc
git clone git://hhvn.uk/rc
Log | Files | Refs | README | LICENSE

history.1 (6445B)


      1 .\" history.1
      2 .\"-------
      3 .\" See rc.1 for man page portability notes.
      4 .\"-------
      5 .\" Dd	distance to space vertically before a "display"
      6 .\" These are what n/troff use for interparagraph distance
      7 .\"-------
      8 .if t .nr Dd .4v
      9 .if n .nr Dd 1v
     10 .\"-------
     11 .\" Ds	begin a display, indented .5 inches from the surrounding text.
     12 .\"
     13 .\" Note that uses of Ds and De may NOT be nested.
     14 .\"-------
     15 .de Ds
     16 .\" .RS \\$1
     17 .sp \\n(Ddu
     18 .in +0.5i
     19 .nf
     20 ..
     21 .\"-------
     22 .\" De	end a display (no trailing vertical spacing)
     23 .\"-------
     24 .de De
     25 .fi
     26 .in
     27 .\" .RE
     28 ..
     29 .\"-------
     30 .\" I stole the Xf macro from the -man macros on my machine (originally
     31 .\" "}S", I renamed it so that it won't conflict).
     32 .\"-------
     33 .\" Set Cf to the name of the constant width font.
     34 .\" It will be "C" or "(CW", typically.
     35 .\" NOTEZ BIEN the lines defining Cf must have no trailing white space:
     36 .\"-------
     37 .if t .ds Cf C
     38 .if n .ds Cf R
     39 .\"-------
     40 .\" Rc - Alternate Roman and Courier
     41 .\"-------
     42 .de Rc
     43 .Xf R \\*(Cf \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
     44 ..
     45 .\"-------
     46 .\" Ic - Alternate Italic and Courier
     47 .\"-------
     48 .de Ic
     49 .Xf I \\*(Cf \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
     50 ..
     51 .\"-------
     52 .\" Bc - Alternate Bold and Courier
     53 .\"-------
     54 .de Bc
     55 .Xf B \\*(Cf \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
     56 ..
     57 .\"-------
     58 .\" Cr - Alternate Courier and Roman
     59 .\"-------
     60 .de Cr
     61 .Xf \\*(Cf R \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
     62 ..
     63 .\"-------
     64 .\" Ci - Alternate Courier and Italic
     65 .\"-------
     66 .de Ci
     67 .Xf \\*(Cf I \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
     68 ..
     69 .\"-------
     70 .\" Cb - Alternate Courier and Bold
     71 .\"-------
     72 .de Cb
     73 .Xf \\*(Cf B \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
     74 ..
     75 .\"-------
     76 .\" Xf - Alternate fonts
     77 .\"
     78 .\" \$1 - first font
     79 .\" \$2 - second font
     80 .\" \$3 - desired word with embedded font changes, built up by recursion
     81 .\" \$4 - text for first font
     82 .\" \$5 - \$9 - remaining args
     83 .\"
     84 .\" Every time we are called:
     85 .\"
     86 .\" If		there is something in \$4
     87 .\" then	Call ourself with the fonts switched,
     88 .\"		with a new word made of the current word (\$3) and \$4
     89 .\"		rendered in the first font,
     90 .\"		and with the remaining args following \$4.
     91 .\" else	We are done recursing.  \$3 holds the desired output
     92 .\"		word.  We emit \$3, change to Roman font, and restore
     93 .\"		the point size to the default.
     94 .\" fi
     95 .\"
     96 .\" Use Xi to add a little bit of space after italic text.
     97 .\"-------
     98 .de Xf
     99 .ds Xi
    100 .\"-------
    101 .\" I used to test for the italic font both by its font position
    102 .\" and its name.  Now just test by its name.
    103 .\"
    104 .\" .if "\\$1"2" .if !"\\$5"" .ds Xi \^
    105 .\"-------
    106 .if "\\$1"I" .if !"\\$5"" .ds Xi \^
    107 .\"-------
    108 .\" This is my original code to deal with the recursion.
    109 .\" Evidently some nroffs can't deal with it.
    110 .\"-------
    111 .\" .ie !"\\$4"" \{\
    112 .\" .	Xf \\$2 \\$1 "\\$3\\f\\$1\\$4\\*(Xi" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
    113 .\" .\}
    114 .\" .el \{\\$3
    115 .\" .	ft R	\" Restore the default font, since we don't know
    116 .\" .		\" what the last font change was.
    117 .\" .	ps 10	\" Restore the default point size, since it might
    118 .\" .		\" have been changed by an argument to this macro.
    119 .\" .\}
    120 .\"-------
    121 .\" Here is more portable (though less pretty) code to deal with
    122 .\" the recursion.
    123 .\"-------
    124 .if !"\\$4"" .Xf \\$2 \\$1 "\\$3\\f\\$1\\$4\\*(Xi" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
    125 .if "\\$4"" \\$3\fR\s10
    126 ..
    127 .TH HISTORY 1 "30 July 1991"
    128 .SH NAME
    129 \-, \-\|\-, \-p, \-\|\-p \- shell history programs
    130 .SH SYNOPSIS
    131 .B \-
    132 .RI [ pattern ...]
    133 .RI [ substitution ...]
    134 .SH DESCRIPTION
    135 This set of programs provides a crude history mechanism for the shell
    136 .IR rc (1).
    137 It is based on the v8 UNIX programs
    138 .IR = ,
    139 .IR == ,
    140 etc.
    141 .PP
    142 The program
    143 .RI `` \- ''
    144 runs the shell on the command it is requested to find.
    145 The program
    146 .RI `` \-\|\- ''
    147 edits that command first.
    148 The programs
    149 .RI `` \-p ''
    150 and
    151 .RI `` \-\|\-p ''
    152 are similar, except that they print the final command on their standard
    153 output instead of running the shell.
    154 .PP
    155 The commands work by looking for a file
    156 named by the environment variable
    157 .Cr $history ,
    158 and by searching for previous commands in this file.
    159 Old commands can be edited,
    160 or simply re-executed according to the rules below:
    161 .PP
    162 A command is searched for by examining the lines in
    163 .Cr $history
    164 in reverse order.
    165 Lines which contain a previous invocation of the history
    166 program itself are ignored.
    167 If one or more
    168 .I pattern
    169 is supplied on the command line,
    170 then the patterns are used as a means of
    171 limiting the search.
    172 Patterns match any substring of a previous command,
    173 and if more than one pattern is present then all patterns must be
    174 matched before a command is selected.
    175 .PP
    176 Substitutions may also be specified on the command line.
    177 These have the syntax:
    178 .Ds
    179 .Ic old :[:...] new
    180 .De
    181 .PP
    182 (Note that the
    183 .I old
    184 pattern is used as a search-limiting pattern also.)
    185 Substitutions happen from left to right and are repeated according to the
    186 number of colons specified.
    187 .PP
    188 Finally, if the program was invoked as
    189 .RI `` -- ''
    190 or
    191 .RI `` --p '',
    192 a command may be edited in a crude line-mode fashion.  The line to be
    193 edited is printed out, and below it the user supplies modifications to
    194 the command.
    195 .TP
    196 .B any character except those below
    197 Replaces the character above.
    198 .TP
    199 .B space or tab
    200 Skips over the above character(s).
    201 .TP
    202 .B #
    203 Deletes one character.
    204 .TP
    205 .B %
    206 Replaces one character with a space.
    207 .TP
    208 .B ^
    209 Inserts the rest of the typed line just before the character.
    210 .TP
    211 .B $
    212 Deletes the rest of the line from that character on, and replaces
    213 it with the rest of the typed line.
    214 .TP
    215 .B +
    216 Appends the rest of the typed line.
    217 .TP
    218 .B \-
    219 Backs up to a previous command satisfying the same matching
    220 constraints.
    221 .TP
    222 .B end of line
    223 If any changes have been made, the command is printed out again for
    224 further editing.  If no changes have been made, the command is executed
    225 or printed, and the program exits.
    226 .TP
    227 .B end of file
    228 If an end-of-file is read from the keyboard by the editor,
    229 it aborts with exit status 1 and does not produce any output.
    230 .SH EXAMPLES
    231 The history programs work best when their output is reinterpreted by
    232 the shell using an
    233 .Cr eval
    234 command.
    235 This can be achieved by writing a shell function to perform the
    236 reinterpretation:
    237 .Ds
    238 .Cr "fn - -- {"
    239 .Cr "	comm = \`{$0^p $*}"
    240 .Cr "	if (! ~ $#comm 0) {"
    241 .Cr "		echo $comm >[1=2]"
    242 .Cr "		eval $comm"
    243 .Cr "	}"
    244 .Cr "}"
    245 .De
    246 .PP
    247 Stuttering the `:' in a substitution allows things like:
    248 .Ds
    249 ; prog 1 2 3 abc > /very/long/path/abc.out
    250 etc.
    251 - prog abc::xyz
    252 prog 1 2 3 xyz > /very/long/path/xyz.out
    253 ;
    254 .De