Imported from ../bash-2.0.tar.gz.
This commit is contained in:
parent
726f63884d
commit
ccc6cda312
502 changed files with 91988 additions and 69123 deletions
|
|
@ -1,10 +1,11 @@
|
|||
# This makefile for History library documentation is in -*- text -*- mode.
|
||||
# This makefile for Readline library documentation is in -*- text -*- mode.
|
||||
# Emacs likes it that way.
|
||||
TEXI2DVI = texi2dvi
|
||||
|
||||
DOC_SUPPORT = ../../doc-support/
|
||||
TEXINDEX = $(DOC_SUPPORT)/texindex
|
||||
RM = rm -f
|
||||
|
||||
TEX = tex
|
||||
INSTALL_DATA = cp
|
||||
infodir = /usr/local/info
|
||||
|
||||
RLSRC = rlman.texinfo rluser.texinfo rltech.texinfo
|
||||
HISTSRC = hist.texinfo hsuser.texinfo hstech.texinfo
|
||||
|
|
@ -12,26 +13,23 @@ HISTSRC = hist.texinfo hsuser.texinfo hstech.texinfo
|
|||
DVIOBJ = readline.dvi history.dvi
|
||||
INFOOBJ = readline.info history.info
|
||||
PSOBJ = readline.ps history.ps
|
||||
HTMLOBJ = readline.html history.html
|
||||
|
||||
all: info dvi
|
||||
all: info dvi html
|
||||
|
||||
readline.dvi: $(RLSRC)
|
||||
$(TEX) rlman.texinfo
|
||||
$(TEXINDEX) rlman.??
|
||||
$(TEX) rlman.texinfo
|
||||
$(TEXI2DVI) rlman.texinfo
|
||||
mv rlman.dvi readline.dvi
|
||||
|
||||
readline.info: $(RLSRC)
|
||||
makeinfo rlman.texinfo
|
||||
makeinfo --no-split -o $@ rlman.texinfo
|
||||
|
||||
history.dvi: ${HISTSRC}
|
||||
$(TEX) hist.texinfo
|
||||
$(TEXINDEX) hist.??
|
||||
$(TEX) hist.texinfo
|
||||
$(TEXI2DVI) hist.texinfo
|
||||
mv hist.dvi history.dvi
|
||||
|
||||
history.info: ${HISTSRC}
|
||||
makeinfo hist.texinfo
|
||||
makeinfo --no-split -o $@ hist.texinfo
|
||||
|
||||
readline.ps: readline.dvi
|
||||
dvips -D 300 -o $@ readline.dvi
|
||||
|
|
@ -39,17 +37,33 @@ readline.ps: readline.dvi
|
|||
history.ps: history.dvi
|
||||
dvips -D 300 -o $@ history.dvi
|
||||
|
||||
readline.html: ${RLSRC}
|
||||
texi2html rlman.texinfo
|
||||
sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman.html > readline.html
|
||||
sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman_toc.html > readline_toc.html
|
||||
rm -f rlman.html rlman_toc.html
|
||||
|
||||
history.html: ${HISTSRC}
|
||||
texi2html hist.texinfo
|
||||
sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist.html > history.html
|
||||
sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist_toc.html > history_toc.html
|
||||
rm -f hist.html hist_toc.html
|
||||
|
||||
info: $(INFOOBJ)
|
||||
dvi: $(DVIOBJ)
|
||||
ps: $(PSOBJ)
|
||||
html: $(HTMLOBJ)
|
||||
|
||||
|
||||
$(TEXINDEX):
|
||||
(cd $(DOC_SUPPORT); $(MAKE) $(MFLAGS) CFLAGS='$(CFLAGS)' texindex)
|
||||
|
||||
distclean mostlyclean clean:
|
||||
rm -f *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
clean:
|
||||
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
*.fns *.kys *.tps *.vrs *.o core
|
||||
|
||||
maintainer-clean realclean: clean
|
||||
rm -f *.dvi *.info *.info-* *.ps
|
||||
distclean: clean
|
||||
mostlyclean: clean
|
||||
|
||||
maintainer-clean: clean
|
||||
$(RM) *.dvi *.info *.info-* *.ps *.html
|
||||
|
||||
install: info
|
||||
${INSTALL_DATA} readline.info $(infodir)/readline.info
|
||||
${INSTALL_DATA} history.info $(infodir)/history.info
|
||||
|
|
|
|||
|
|
@ -7,20 +7,20 @@
|
|||
@setchapternewpage odd
|
||||
|
||||
@ignore
|
||||
last change: Wed Jul 20 09:57:17 EDT 1994
|
||||
last change: Thu Mar 21 16:07:29 EST 1996
|
||||
@end ignore
|
||||
|
||||
@set EDITION 2.0
|
||||
@set VERSION 2.0
|
||||
@set UPDATED 20 July 1994
|
||||
@set UPDATE-MONTH July 1994
|
||||
@set EDITION 2.1
|
||||
@set VERSION 2.1
|
||||
@set UPDATED 21 March 1996
|
||||
@set UPDATE-MONTH March 1996
|
||||
|
||||
@ifinfo
|
||||
This document describes the GNU History library, a programming tool that
|
||||
provides a consistent user interface for recalling lines of previously
|
||||
typed input.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
|
|
@ -45,7 +45,6 @@ by the Foundation.
|
|||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@sp 10
|
||||
@title GNU History Library
|
||||
@subtitle Edition @value{EDITION}, for @code{History Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATE-MONTH}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,744 +0,0 @@
|
|||
This is Info file history.info, produced by Makeinfo-1.55 from the
|
||||
input file hist.texinfo.
|
||||
|
||||
This document describes the GNU History library, a programming tool
|
||||
that provides a consistent user interface for recalling lines of
|
||||
previously typed input.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this
|
||||
manual provided the copyright notice and this permission notice pare
|
||||
preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of
|
||||
this manual under the conditions for verbatim copying, provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this
|
||||
manual into another language, under the above conditions for modified
|
||||
versions, except that this permission notice may be stated in a
|
||||
translation approved by the Foundation.
|
||||
|
||||
|
||||
File: history.info, Node: Top, Next: Using History Interactively, Prev: (DIR), Up: (DIR)
|
||||
|
||||
GNU History Library
|
||||
*******************
|
||||
|
||||
This document describes the GNU History library, a programming tool
|
||||
that provides a consistent user interface for recalling lines of
|
||||
previously typed input.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Using History Interactively:: GNU History User's Manual.
|
||||
* Programming with GNU History:: GNU History Programmer's Manual.
|
||||
* Concept Index:: Index of concepts described in this manual.
|
||||
* Function and Variable Index:: Index of externally visible functions
|
||||
and variables.
|
||||
|
||||
|
||||
File: history.info, Node: Using History Interactively, Next: Programming with GNU History, Prev: Top, Up: Top
|
||||
|
||||
Using History Interactively
|
||||
***************************
|
||||
|
||||
This chapter describes how to use the GNU History Library
|
||||
interactively, from a user's standpoint. It should be considered a
|
||||
user's guide. For information on using the GNU History Library in your
|
||||
own programs, *note Programming with GNU History::..
|
||||
|
||||
* Menu:
|
||||
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
|
||||
|
||||
File: history.info, Node: History Interaction, Up: Using History Interactively
|
||||
|
||||
History Interaction
|
||||
===================
|
||||
|
||||
The History library provides a history expansion feature that is
|
||||
similar to the history expansion provided by `csh'. The following text
|
||||
describes the syntax used to manipulate the history information.
|
||||
|
||||
History expansion takes place in two parts. The first is to
|
||||
determine which line from the previous history should be used during
|
||||
substitution. The second is to select portions of that line for
|
||||
inclusion into the current one. The line selected from the previous
|
||||
history is called the "event", and the portions of that line that are
|
||||
acted upon are called "words". The line is broken into words in the
|
||||
same fashion that Bash does, so that several English (or Unix) words
|
||||
surrounded by quotes are considered as one word.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Event Designators:: How to specify which history line to use.
|
||||
* Word Designators:: Specifying which words are of interest.
|
||||
* Modifiers:: Modifying the results of substitution.
|
||||
|
||||
|
||||
File: history.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
|
||||
|
||||
Event Designators
|
||||
-----------------
|
||||
|
||||
An event designator is a reference to a command line entry in the
|
||||
history list.
|
||||
|
||||
`!'
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, = or (.
|
||||
|
||||
`!!'
|
||||
Refer to the previous command. This is a synonym for `!-1'.
|
||||
|
||||
`!n'
|
||||
Refer to command line N.
|
||||
|
||||
`!-n'
|
||||
Refer to the command N lines back.
|
||||
|
||||
`!string'
|
||||
Refer to the most recent command starting with STRING.
|
||||
|
||||
`!?string'[`?']
|
||||
Refer to the most recent command containing STRING.
|
||||
|
||||
`!#'
|
||||
The entire command line typed so far.
|
||||
|
||||
`^string1^string2^'
|
||||
Quick Substitution. Repeat the last command, replacing STRING1
|
||||
with STRING2. Equivalent to `!!:s/string1/string2/'.
|
||||
|
||||
|
||||
File: history.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
|
||||
|
||||
Word Designators
|
||||
----------------
|
||||
|
||||
A : separates the event specification from the word designator. It
|
||||
can be omitted if the word designator begins with a ^, $, * or %.
|
||||
Words are numbered from the beginning of the line, with the first word
|
||||
being denoted by a 0 (zero).
|
||||
|
||||
`0 (zero)'
|
||||
The `0'th word. For many applications, this is the command word.
|
||||
|
||||
`n'
|
||||
The Nth word.
|
||||
|
||||
`^'
|
||||
The first argument; that is, word 1.
|
||||
|
||||
`$'
|
||||
The last argument.
|
||||
|
||||
`%'
|
||||
The word matched by the most recent `?string?' search.
|
||||
|
||||
`x-y'
|
||||
A range of words; `-Y' abbreviates `0-Y'.
|
||||
|
||||
`*'
|
||||
All of the words, except the `0'th. This is a synonym for `1-$'.
|
||||
It is not an error to use * if there is just one word in the event;
|
||||
the empty string is returned in that case.
|
||||
|
||||
`x*'
|
||||
Abbreviates `x-$'
|
||||
|
||||
`x-'
|
||||
Abbreviates `x-$' like `x*', but omits the last word.
|
||||
|
||||
|
||||
File: history.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
|
||||
|
||||
Modifiers
|
||||
---------
|
||||
|
||||
After the optional word designator, you can add a sequence of one or
|
||||
more of the following modifiers, each preceded by a :.
|
||||
|
||||
`h'
|
||||
Remove a trailing pathname component, leaving only the head.
|
||||
|
||||
`r'
|
||||
Remove a trailing suffix of the form `.'SUFFIX, leaving the
|
||||
basename.
|
||||
|
||||
`e'
|
||||
Remove all but the trailing suffix.
|
||||
|
||||
`t'
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
`p'
|
||||
Print the new command but do not execute it.
|
||||
|
||||
`s/old/new/'
|
||||
Substitute NEW for the first occurrence of OLD in the event line.
|
||||
Any delimiter may be used in place of /. The delimiter may be
|
||||
quoted in OLD and NEW with a single backslash. If & appears in
|
||||
NEW, it is replaced by OLD. A single backslash will quote the &.
|
||||
The final delimiter is optional if it is the last character on the
|
||||
input line.
|
||||
|
||||
`&'
|
||||
Repeat the previous substitution.
|
||||
|
||||
`g'
|
||||
Cause changes to be applied over the entire event line. Used in
|
||||
conjunction with `s', as in `gs/old/new/', or with `&'.
|
||||
|
||||
|
||||
File: history.info, Node: Programming with GNU History, Next: Concept Index, Prev: Using History Interactively, Up: Top
|
||||
|
||||
Programming with GNU History
|
||||
****************************
|
||||
|
||||
This chapter describes how to interface programs that you write with
|
||||
the GNU History Library. It should be considered a technical guide.
|
||||
For information on the interactive use of GNU History, *note Using
|
||||
History Interactively::..
|
||||
|
||||
* Menu:
|
||||
|
||||
* Introduction to History:: What is the GNU History library for?
|
||||
* History Storage:: How information is stored.
|
||||
* History Functions:: Functions that you can use.
|
||||
* History Variables:: Variables that control behaviour.
|
||||
* History Programming Example:: Example of using the GNU History Library.
|
||||
|
||||
|
||||
File: history.info, Node: Introduction to History, Next: History Storage, Up: Programming with GNU History
|
||||
|
||||
Introduction to History
|
||||
=======================
|
||||
|
||||
Many programs read input from the user a line at a time. The GNU
|
||||
History library is able to keep track of those lines, associate
|
||||
arbitrary data with each line, and utilize information from previous
|
||||
lines in composing new ones.
|
||||
|
||||
The programmer using the History library has available functions for
|
||||
remembering lines on a history list, associating arbitrary data with a
|
||||
line, removing lines from the list, searching through the list for a
|
||||
line containing an arbitrary text string, and referencing any line in
|
||||
the list directly. In addition, a history "expansion" function is
|
||||
available which provides for a consistent user interface across
|
||||
different programs.
|
||||
|
||||
The user using programs written with the History library has the
|
||||
benefit of a consistent user interface with a set of well-known
|
||||
commands for manipulating the text of previous lines and using that text
|
||||
in new commands. The basic history manipulation commands are similar to
|
||||
the history substitution provided by `csh'.
|
||||
|
||||
If the programmer desires, he can use the Readline library, which
|
||||
includes some history manipulation by default, and has the added
|
||||
advantage of command line editing.
|
||||
|
||||
|
||||
File: history.info, Node: History Storage, Next: History Functions, Prev: Introduction to History, Up: Programming with GNU History
|
||||
|
||||
History Storage
|
||||
===============
|
||||
|
||||
The history list is an array of history entries. A history entry is
|
||||
declared as follows:
|
||||
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
The history list itself might therefore be declared as
|
||||
|
||||
HIST_ENTRY **the_history_list;
|
||||
|
||||
The state of the History library is encapsulated into a single
|
||||
structure:
|
||||
|
||||
/* A structure used to pass the current state of the history stuff around. */
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
int flags;
|
||||
} HISTORY_STATE;
|
||||
|
||||
If the flags member includes `HS_STIFLED', the history has been
|
||||
stifled.
|
||||
|
||||
|
||||
File: history.info, Node: History Functions, Next: History Variables, Prev: History Storage, Up: Programming with GNU History
|
||||
|
||||
History Functions
|
||||
=================
|
||||
|
||||
This section describes the calling sequence for the various functions
|
||||
present in GNU History.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Initializing History and State Management:: Functions to call when you
|
||||
want to use history in a
|
||||
program.
|
||||
* History List Management:: Functions used to manage the list
|
||||
of history entries.
|
||||
* Information About the History List:: Functions returning information about
|
||||
the history list.
|
||||
* Moving Around the History List:: Functions used to change the position
|
||||
in the history list.
|
||||
* Searching the History List:: Functions to search the history list
|
||||
for entries containing a string.
|
||||
* Managing the History File:: Functions that read and write a file
|
||||
containing the history list.
|
||||
* History Expansion:: Functions to perform csh-like history
|
||||
expansion.
|
||||
|
||||
|
||||
File: history.info, Node: Initializing History and State Management, Next: History List Management, Up: History Functions
|
||||
|
||||
Initializing History and State Management
|
||||
-----------------------------------------
|
||||
|
||||
This section describes functions used to initialize and manage the
|
||||
state of the History library when you want to use the history functions
|
||||
in your program.
|
||||
|
||||
- Function: void using_history ()
|
||||
Begin a session in which the history functions might be used. This
|
||||
initializes the interactive variables.
|
||||
|
||||
- Function: HISTORY_STATE * history_get_history_state ()
|
||||
Return a structure describing the current state of the input
|
||||
history.
|
||||
|
||||
- Function: void history_set_history_state (HISTORY_STATE *state)
|
||||
Set the state of the history list according to STATE.
|
||||
|
||||
|
||||
File: history.info, Node: History List Management, Next: Information About the History List, Prev: Initializing History and State Management, Up: History Functions
|
||||
|
||||
History List Management
|
||||
-----------------------
|
||||
|
||||
These functions manage individual entries on the history list, or set
|
||||
parameters managing the list itself.
|
||||
|
||||
- Function: void add_history (char *string)
|
||||
Place STRING at the end of the history list. The associated data
|
||||
field (if any) is set to `NULL'.
|
||||
|
||||
- Function: HIST_ENTRY * remove_history (int which)
|
||||
Remove history entry at offset WHICH from the history. The
|
||||
removed element is returned so you can free the line, data, and
|
||||
containing structure.
|
||||
|
||||
- Function: HIST_ENTRY * replace_history_entry (int which, char *line,
|
||||
char *data)
|
||||
Make the history entry at offset WHICH have LINE and DATA. This
|
||||
returns the old entry so you can dispose of the data. In the case
|
||||
of an invalid WHICH, a `NULL' pointer is returned.
|
||||
|
||||
- Function: void stifle_history (int max)
|
||||
Stifle the history list, remembering only the last MAX entries.
|
||||
|
||||
- Function: int unstifle_history ()
|
||||
Stop stifling the history. This returns the previous amount the
|
||||
history was stifled. The value is positive if the history was
|
||||
stifled, negative if it wasn't.
|
||||
|
||||
- Function: int history_is_stifled ()
|
||||
Returns non-zero if the history is stifled, zero if it is not.
|
||||
|
||||
|
||||
File: history.info, Node: Information About the History List, Next: Moving Around the History List, Prev: History List Management, Up: History Functions
|
||||
|
||||
Information About the History List
|
||||
----------------------------------
|
||||
|
||||
These functions return information about the entire history list or
|
||||
individual list entries.
|
||||
|
||||
- Function: HIST_ENTRY ** history_list ()
|
||||
Return a `NULL' terminated array of `HIST_ENTRY' which is the
|
||||
current input history. Element 0 of this list is the beginning of
|
||||
time. If there is no history, return `NULL'.
|
||||
|
||||
- Function: int where_history ()
|
||||
Returns the offset of the current history element.
|
||||
|
||||
- Function: HIST_ENTRY * current_history ()
|
||||
Return the history entry at the current position, as determined by
|
||||
`where_history ()'. If there is no entry there, return a `NULL'
|
||||
pointer.
|
||||
|
||||
- Function: HIST_ENTRY * history_get (int offset)
|
||||
Return the history entry at position OFFSET, starting from
|
||||
`history_base'. If there is no entry there, or if OFFSET is
|
||||
greater than the history length, return a `NULL' pointer.
|
||||
|
||||
- Function: int history_total_bytes ()
|
||||
Return the number of bytes that the primary history entries are
|
||||
using. This function returns the sum of the lengths of all the
|
||||
lines in the history.
|
||||
|
||||
|
||||
File: history.info, Node: Moving Around the History List, Next: Searching the History List, Prev: Information About the History List, Up: History Functions
|
||||
|
||||
Moving Around the History List
|
||||
------------------------------
|
||||
|
||||
These functions allow the current index into the history list to be
|
||||
set or changed.
|
||||
|
||||
- Function: int history_set_pos (int pos)
|
||||
Set the position in the history list to POS, an absolute index
|
||||
into the list.
|
||||
|
||||
- Function: HIST_ENTRY * previous_history ()
|
||||
Back up the current history offset to the previous history entry,
|
||||
and return a pointer to that entry. If there is no previous
|
||||
entry, return a `NULL' pointer.
|
||||
|
||||
- Function: HIST_ENTRY * next_history ()
|
||||
Move the current history offset forward to the next history entry,
|
||||
and return the a pointer to that entry. If there is no next
|
||||
entry, return a `NULL' pointer.
|
||||
|
||||
|
||||
File: history.info, Node: Searching the History List, Next: Managing the History File, Prev: Moving Around the History List, Up: History Functions
|
||||
|
||||
Searching the History List
|
||||
--------------------------
|
||||
|
||||
These functions allow searching of the history list for entries
|
||||
containing a specific string. Searching may be performed both forward
|
||||
and backward from the current history position. The search may be
|
||||
"anchored", meaning that the string must match at the beginning of the
|
||||
history entry.
|
||||
|
||||
- Function: int history_search (char *string, int direction)
|
||||
Search the history for STRING, starting at the current history
|
||||
offset. If DIRECTION < 0, then the search is through previous
|
||||
entries, else through subsequent. If STRING is found, then the
|
||||
current history index is set to that history entry, and the value
|
||||
returned is the offset in the line of the entry where STRING was
|
||||
found. Otherwise, nothing is changed, and a -1 is returned.
|
||||
|
||||
- Function: int history_search_prefix (char *string, int direction)
|
||||
Search the history for STRING, starting at the current history
|
||||
offset. The search is anchored: matching lines must begin with
|
||||
STRING. If DIRECTION < 0, then the search is through previous
|
||||
entries, else through subsequent. If STRING is found, then the
|
||||
current history index is set to that entry, and the return value
|
||||
is 0. Otherwise, nothing is changed, and a -1 is returned.
|
||||
|
||||
- Function: int history_search_pos (char *string, int direction, int
|
||||
pos)
|
||||
Search for STRING in the history list, starting at POS, an
|
||||
absolute index into the list. If DIRECTION is negative, the search
|
||||
proceeds backward from POS, otherwise forward. Returns the
|
||||
absolute index of the history element where STRING was found, or
|
||||
-1 otherwise.
|
||||
|
||||
|
||||
File: history.info, Node: Managing the History File, Next: History Expansion, Prev: Searching the History List, Up: History Functions
|
||||
|
||||
Managing the History File
|
||||
-------------------------
|
||||
|
||||
The History library can read the history from and write it to a file.
|
||||
This section documents the functions for managing a history file.
|
||||
|
||||
- Function: int read_history (char *filename)
|
||||
Add the contents of FILENAME to the history list, a line at a
|
||||
time. If FILENAME is `NULL', then read from `~/.history'.
|
||||
Returns 0 if successful, or errno if not.
|
||||
|
||||
- Function: int read_history_range (char *filename, int from, int to)
|
||||
Read a range of lines from FILENAME, adding them to the history
|
||||
list. Start reading at line FROM and end at TO. If FROM is zero,
|
||||
start at the beginning. If TO is less than FROM, then read until
|
||||
the end of the file. If FILENAME is `NULL', then read from
|
||||
`~/.history'. Returns 0 if successful, or `errno' if not.
|
||||
|
||||
- Function: int write_history (char *filename)
|
||||
Write the current history to FILENAME, overwriting FILENAME if
|
||||
necessary. If FILENAME is `NULL', then write the history list to
|
||||
`~/.history'. Values returned are as in `read_history ()'.
|
||||
|
||||
- Function: int append_history (int nelements, char *filename)
|
||||
Append the last NELEMENTS of the history list to FILENAME.
|
||||
|
||||
- Function: int history_truncate_file (char *filename, int nlines)
|
||||
Truncate the history file FILENAME, leaving only the last NLINES
|
||||
lines.
|
||||
|
||||
|
||||
File: history.info, Node: History Expansion, Prev: Managing the History File, Up: History Functions
|
||||
|
||||
History Expansion
|
||||
-----------------
|
||||
|
||||
These functions implement `csh'-like history expansion.
|
||||
|
||||
- Function: int history_expand (char *string, char **output)
|
||||
Expand STRING, placing the result into OUTPUT, a pointer to a
|
||||
string (*note History Interaction::.). Returns:
|
||||
`0'
|
||||
If no expansions took place (or, if the only change in the
|
||||
text was the de-slashifying of the history expansion
|
||||
character);
|
||||
|
||||
`1'
|
||||
if expansions did take place;
|
||||
|
||||
`-1'
|
||||
if there was an error in expansion;
|
||||
|
||||
`2'
|
||||
if the returned line should only be displayed, but not
|
||||
executed, as with the `:p' modifier (*note Modifiers::.).
|
||||
|
||||
If an error ocurred in expansion, then OUTPUT contains a
|
||||
descriptive error message.
|
||||
|
||||
- Function: char * history_arg_extract (int first, int last, char
|
||||
*string)
|
||||
Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in Bash.
|
||||
|
||||
- Function: char * get_history_event (char *string, int *cindex, int
|
||||
qchar)
|
||||
Returns the text of the history event beginning at STRING +
|
||||
*CINDEX. *CINDEX is modified to point to after the event
|
||||
specifier. At function entry, CINDEX points to the index into
|
||||
STRING where the history event specification begins. QCHAR is a
|
||||
character that is allowed to end the event specification in
|
||||
addition to the "normal" terminating characters.
|
||||
|
||||
- Function: char ** history_tokenize (char *string)
|
||||
Return an array of tokens parsed out of STRING, much as the shell
|
||||
might. The tokens are split on white space and on the characters
|
||||
`()<>;&|$', and shell quoting conventions are obeyed.
|
||||
|
||||
|
||||
File: history.info, Node: History Variables, Next: History Programming Example, Prev: History Functions, Up: Programming with GNU History
|
||||
|
||||
History Variables
|
||||
=================
|
||||
|
||||
This section describes the externally visible variables exported by
|
||||
the GNU History Library.
|
||||
|
||||
- Variable: int history_base
|
||||
The logical offset of the first entry in the history list.
|
||||
|
||||
- Variable: int history_length
|
||||
The number of entries currently stored in the history list.
|
||||
|
||||
- Variable: int max_input_history
|
||||
The maximum number of history entries. This must be changed using
|
||||
`stifle_history ()'.
|
||||
|
||||
- Variable: char history_expansion_char
|
||||
The character that starts a history event. The default is `!'.
|
||||
|
||||
- Variable: char history_subst_char
|
||||
The character that invokes word substitution if found at the start
|
||||
of a line. The default is `^'.
|
||||
|
||||
- Variable: char history_comment_char
|
||||
During tokenization, if this character is seen as the first
|
||||
character of a word, then it and all subsequent characters up to a
|
||||
newline are ignored, suppressing history expansion for the
|
||||
remainder of the line. This is disabled by default.
|
||||
|
||||
- Variable: char * history_no_expand_chars
|
||||
The list of characters which inhibit history expansion if found
|
||||
immediately following HISTORY_EXPANSION_CHAR. The default is
|
||||
whitespace and `='.
|
||||
|
||||
|
||||
File: history.info, Node: History Programming Example, Prev: History Variables, Up: Programming with GNU History
|
||||
|
||||
History Programming Example
|
||||
===========================
|
||||
|
||||
The following program demonstrates simple use of the GNU History
|
||||
Library.
|
||||
|
||||
main ()
|
||||
{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
||||
line[0] = 0;
|
||||
|
||||
using_history ();
|
||||
while (!done)
|
||||
{
|
||||
printf ("history$ ");
|
||||
fflush (stdout);
|
||||
t = fgets (line, sizeof (line) - 1, stdin);
|
||||
if (t && *t)
|
||||
{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
}
|
||||
|
||||
if (!t)
|
||||
strcpy (line, "quit");
|
||||
|
||||
if (line[0])
|
||||
{
|
||||
char *expansion;
|
||||
int result;
|
||||
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
|
||||
if (result < 0 || result == 2)
|
||||
{
|
||||
free (expansion);
|
||||
continue;
|
||||
}
|
||||
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
}
|
||||
|
||||
if (strcmp (line, "quit") == 0)
|
||||
done = 1;
|
||||
else if (strcmp (line, "save") == 0)
|
||||
write_history ("history_file");
|
||||
else if (strcmp (line, "read") == 0)
|
||||
read_history ("history_file");
|
||||
else if (strcmp (line, "list") == 0)
|
||||
{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
printf ("%d: %s\n", i + history_base, the_list[i]->line);
|
||||
}
|
||||
else if (strncmp (line, "delete", 6) == 0)
|
||||
{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File: history.info, Node: Concept Index, Next: Function and Variable Index, Prev: Programming with GNU History, Up: Top
|
||||
|
||||
Concept Index
|
||||
*************
|
||||
|
||||
* Menu:
|
||||
|
||||
* anchored search: Searching the History List.
|
||||
* event designators: Event Designators.
|
||||
* expansion: History Interaction.
|
||||
* history events: Event Designators.
|
||||
* History Searching: Searching the History List.
|
||||
|
||||
|
||||
File: history.info, Node: Function and Variable Index, Prev: Concept Index, Up: Top
|
||||
|
||||
Function and Variable Index
|
||||
***************************
|
||||
|
||||
* Menu:
|
||||
|
||||
* add_history: History List Management.
|
||||
* append_history: Managing the History File.
|
||||
* current_history: Information About the History List.
|
||||
* get_history_event: History Expansion.
|
||||
* history_arg_extract: History Expansion.
|
||||
* history_base: History Variables.
|
||||
* history_comment_char: History Variables.
|
||||
* history_expand: History Expansion.
|
||||
* history_expansion_char: History Variables.
|
||||
* history_get: Information About the History List.
|
||||
* history_get_history_state: Initializing History and State Management.
|
||||
* history_is_stifled: History List Management.
|
||||
* history_length: History Variables.
|
||||
* history_list: Information About the History List.
|
||||
* history_no_expand_chars: History Variables.
|
||||
* history_search: Searching the History List.
|
||||
* history_search_pos: Searching the History List.
|
||||
* history_search_prefix: Searching the History List.
|
||||
* history_set_history_state: Initializing History and State Management.
|
||||
* history_set_pos: Moving Around the History List.
|
||||
* history_subst_char: History Variables.
|
||||
* history_tokenize: History Expansion.
|
||||
* history_total_bytes: Information About the History List.
|
||||
* history_truncate_file: Managing the History File.
|
||||
* max_input_history: History Variables.
|
||||
* next_history: Moving Around the History List.
|
||||
* previous_history: Moving Around the History List.
|
||||
* read_history: Managing the History File.
|
||||
* read_history_range: Managing the History File.
|
||||
* remove_history: History List Management.
|
||||
* replace_history_entry: History List Management.
|
||||
* stifle_history: History List Management.
|
||||
* unstifle_history: History List Management.
|
||||
* using_history: Initializing History and State Management.
|
||||
* where_history: Information About the History List.
|
||||
* write_history: Managing the History File.
|
||||
|
||||
|
||||
|
||||
Tag Table:
|
||||
Node: Top975
|
||||
Node: Using History Interactively1569
|
||||
Node: History Interaction2077
|
||||
Node: Event Designators3122
|
||||
Node: Word Designators3952
|
||||
Node: Modifiers4936
|
||||
Node: Programming with GNU History6065
|
||||
Node: Introduction to History6791
|
||||
Node: History Storage8112
|
||||
Node: History Functions9205
|
||||
Node: Initializing History and State Management10176
|
||||
Node: History List Management10968
|
||||
Node: Information About the History List12396
|
||||
Node: Moving Around the History List13702
|
||||
Node: Searching the History List14587
|
||||
Node: Managing the History File16419
|
||||
Node: History Expansion17925
|
||||
Node: History Variables19769
|
||||
Node: History Programming Example21138
|
||||
Node: Concept Index23742
|
||||
Node: Function and Variable Index24223
|
||||
|
||||
End Tag Table
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
|||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1991, 1994, 1996 Free Software Foundation, Inc.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this manual
|
||||
|
|
@ -168,6 +168,10 @@ This returns the old entry so you can dispose of the data. In the case
|
|||
of an invalid @var{which}, a @code{NULL} pointer is returned.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void clear_history ()
|
||||
Clear the history list by deleting all the entries.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void stifle_history (int max)
|
||||
Stifle the history list, remembering only the last @var{max} entries.
|
||||
@end deftypefun
|
||||
|
|
@ -400,6 +404,17 @@ following @var{history_expansion_char}. The default is whitespace and
|
|||
@samp{=}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} history_search_delimiter_chars
|
||||
The list of additional characters which can delimit a history search
|
||||
string, in addition to whitespace, @samp{:} and @samp{?} in the case of
|
||||
a substring search. The default is empty.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_quotes_inhibit_expansion
|
||||
If non-zero, single-quoted words are not scanned for the history expansion
|
||||
character. The default value is 0.
|
||||
@end deftypevar
|
||||
|
||||
@node History Programming Example
|
||||
@section History Programming Example
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1991, 1996 Free Software Foundation, Inc.
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this manual
|
||||
|
|
@ -39,26 +39,124 @@ information on using the GNU History Library in your own programs,
|
|||
@pxref{Programming with GNU History}.
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
@menu
|
||||
* Bash History Facilities:: How Bash lets you manipulate your command
|
||||
history.
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
@menu
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
@node Bash History Facilities
|
||||
@section Bash History Facilities
|
||||
@cindex command history
|
||||
@cindex history list
|
||||
|
||||
When the @samp{-o history} option to the @code{set} builtin
|
||||
is enabled (@pxref{The Set Builtin}),
|
||||
the shell provides access to the @var{command history},
|
||||
the list of commands previously typed. The text of the last
|
||||
@code{HISTSIZE}
|
||||
commands (default 500) is saved in a history list. The shell
|
||||
stores each command in the history list prior to parameter and
|
||||
variable expansion
|
||||
but after history expansion is performed, subject to the
|
||||
values of the shell variables
|
||||
@code{HISTIGNORE} and @code{HISTCONTROL}.
|
||||
When the shell starts up, the history is initialized from the
|
||||
file named by the @code{HISTFILE} variable (default @file{~/.bash_history}).
|
||||
@code{HISTFILE} is truncated, if necessary, to contain no more than
|
||||
the number of lines specified by the value of the @code{HISTFILESIZE}
|
||||
variable. When an interactive shell exits, the last
|
||||
@code{HISTSIZE} lines are copied from the history list to @code{HISTFILE}.
|
||||
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
|
||||
the lines are appended to the history file,
|
||||
otherwise the history file is overwritten.
|
||||
If @code{HISTFILE}
|
||||
is unset, or if the history file is unwritable, the history is
|
||||
not saved. After saving the history, the history file is truncated
|
||||
to contain no more than @code{$HISTFILESIZE}
|
||||
lines. If @code{HISTFILESIZE} is not set, no truncation is performed.
|
||||
|
||||
The builtin command @code{fc} (@pxref{Korn Shell Builtins})
|
||||
may be used to list or edit and re-execute a portion of
|
||||
the history list. The @code{history} builtin (@pxref{C Shell Builtins})
|
||||
can be used to display or modify the history list and
|
||||
manipulate the history file.
|
||||
When using the command-line editing, search commands
|
||||
are available in each editing mode that provide access to the
|
||||
history list.
|
||||
|
||||
The shell allows control over which commands are saved on the history
|
||||
list. The @code{HISTCONTROL} and @code{HISTIGNORE}
|
||||
variables may be set to cause the shell to save only a subset of the
|
||||
commands entered.
|
||||
The @code{cmdhist}
|
||||
shell option, if enabled, causes the shell to attempt to save each
|
||||
line of a multi-line command in the same history entry, adding
|
||||
semicolons where necessary to preserve syntactic correctness.
|
||||
The @code{lithist}
|
||||
shell option causes the shell to save the command with embedded newlines
|
||||
instead of semicolons.
|
||||
@xref{Bash Builtins} for a description of @code{shopt}.
|
||||
@end ifset
|
||||
|
||||
@node History Interaction
|
||||
@section History Interaction
|
||||
@cindex expansion
|
||||
@section Interactive History Expansion
|
||||
@cindex history expansion
|
||||
|
||||
The History library provides a history expansion feature that is similar
|
||||
to the history expansion provided by @code{csh}. The following text
|
||||
to the history expansion provided by @code{csh}. This section
|
||||
describes the syntax used to manipulate the history information.
|
||||
|
||||
History expansions introduce words from the history list into
|
||||
the input stream, making it easy to repeat commands, insert the
|
||||
arguments to a previous command into the current input line, or
|
||||
fix errors in previous commands quickly.
|
||||
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
which line from the previous history should be used during substitution.
|
||||
The second is to select portions of that line for inclusion into the
|
||||
current one. The line selected from the previous history is called the
|
||||
@dfn{event}, and the portions of that line that are acted upon are
|
||||
called @dfn{words}. The line is broken into words in the same fashion
|
||||
called @dfn{words}. Various @dfn{modifiers} are available to manipulate
|
||||
the selected words. The line is broken into words in the same fashion
|
||||
that Bash does, so that several English (or Unix) words
|
||||
surrounded by quotes are considered as one word.
|
||||
History expansions are introduced by the appearance of the
|
||||
history expansion character, which is @samp{!} by default.
|
||||
@ifset BashFeatures
|
||||
Only @samp{\} and @samp{'} may be used to escape the history expansion
|
||||
character.
|
||||
@end ifset
|
||||
|
||||
@ifset BashFeatures
|
||||
Several shell options settable with the @code{shopt}
|
||||
builtin (@pxref{Bash Builtins}) may be used to tailor
|
||||
the behavior of history expansion. If the
|
||||
@code{histverify} shell option is enabled, and Readline
|
||||
is being used, history substitutions are not immediately passed to
|
||||
the shell parser.
|
||||
Instead, the expanded line is reloaded into the Readline
|
||||
editing buffer for further modification.
|
||||
If Readline is being used, and the @code{histreedit}
|
||||
shell option is enabled, a failed history expansion will be
|
||||
reloaded into the Readline editing buffer for correction.
|
||||
The @samp{-p} option to the @code{history} builtin command
|
||||
may be used to see what a history expansion will do before using it.
|
||||
The @samp{-s} option to the @code{history} builtin may be used to
|
||||
add commands to the end of the history list without actually executing
|
||||
them, so that they are available for subsequent recall.
|
||||
|
||||
The shell allows control of the various characters used by the
|
||||
history expansion mechanism with the @code{histchars} variable.
|
||||
@end ifset
|
||||
|
||||
@menu
|
||||
* Event Designators:: How to specify which history line to use.
|
||||
|
|
@ -80,92 +178,100 @@ history list.
|
|||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, @key{=} or @key{(}.
|
||||
|
||||
@item @code{!!}
|
||||
Refer to the previous command. This is a synonym for @code{!-1}.
|
||||
|
||||
@item @code{!n}
|
||||
@item @code{!@var{n}}
|
||||
Refer to command line @var{n}.
|
||||
|
||||
@item @code{!-n}
|
||||
@item @code{!-@var{n}}
|
||||
Refer to the command @var{n} lines back.
|
||||
|
||||
@item @code{!string}
|
||||
@item @code{!!}
|
||||
Refer to the previous command. This is a synonym for @samp{!-1}.
|
||||
|
||||
@item @code{!@var{string}}
|
||||
Refer to the most recent command starting with @var{string}.
|
||||
|
||||
@item @code{!?string}[@code{?}]
|
||||
Refer to the most recent command containing @var{string}.
|
||||
@item @code{!?@var{string}[?]}
|
||||
Refer to the most recent command containing @var{string}. The trailing
|
||||
@samp{?} may be omitted if the @var{string} is followed immediately by
|
||||
a newline.
|
||||
|
||||
@item @code{^@var{string1}^@var{string2}^}
|
||||
Quick Substitution. Repeat the last command, replacing @var{string1}
|
||||
with @var{string2}. Equivalent to
|
||||
@code{!!:s/@var{string1}/@var{string2}/}.
|
||||
|
||||
@item @code{!#}
|
||||
The entire command line typed so far.
|
||||
|
||||
@item @code{^string1^string2^}
|
||||
Quick Substitution. Repeat the last command, replacing @var{string1}
|
||||
with @var{string2}. Equivalent to
|
||||
@code{!!:s/string1/string2/}.
|
||||
|
||||
@end table
|
||||
|
||||
@node Word Designators
|
||||
@subsection Word Designators
|
||||
|
||||
A @key{:} separates the event specification from the word designator. It
|
||||
can be omitted if the word designator begins with a @key{^}, @key{$},
|
||||
@key{*} or @key{%}. Words are numbered from the beginning of the line,
|
||||
with the first word being denoted by a 0 (zero).
|
||||
Word designators are used to select desired words from the event.
|
||||
A @samp{:} separates the event specification from the word designator. It
|
||||
can be omitted if the word designator begins with a @samp{^}, @samp{$},
|
||||
@samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning
|
||||
of the line, with the first word being denoted by 0 (zero). Words are
|
||||
inserted into the current line separated by single spaces.
|
||||
|
||||
@table @code
|
||||
|
||||
@item 0 (zero)
|
||||
The @code{0}th word. For many applications, this is the command word.
|
||||
|
||||
@item n
|
||||
@item @var{n}
|
||||
The @var{n}th word.
|
||||
|
||||
@item ^
|
||||
The first argument; that is, word 1.
|
||||
The first argument; that is, word 1.
|
||||
|
||||
@item $
|
||||
The last argument.
|
||||
|
||||
@item %
|
||||
The word matched by the most recent @code{?string?} search.
|
||||
The word matched by the most recent @samp{?@var{string}?} search.
|
||||
|
||||
@item x-y
|
||||
A range of words; @code{-@var{y}} abbreviates @code{0-@var{y}}.
|
||||
@item @var{x}-@var{y}
|
||||
A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
|
||||
|
||||
@item *
|
||||
All of the words, except the @code{0}th. This is a synonym for @code{1-$}.
|
||||
It is not an error to use @key{*} if there is just one word in the event;
|
||||
All of the words, except the @code{0}th. This is a synonym for @samp{1-$}.
|
||||
It is not an error to use @samp{*} if there is just one word in the event;
|
||||
the empty string is returned in that case.
|
||||
|
||||
@item x*
|
||||
Abbreviates @code{x-$}
|
||||
@item @var{x}*
|
||||
Abbreviates @samp{@var{x}-$}
|
||||
|
||||
@item x-
|
||||
Abbreviates @code{x-$} like @code{x*}, but omits the last word.
|
||||
@item @var{x}-
|
||||
Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
|
||||
|
||||
@end table
|
||||
|
||||
If a word designator is supplied without an event specification, the
|
||||
previous command is used as the event.
|
||||
|
||||
@node Modifiers
|
||||
@subsection Modifiers
|
||||
|
||||
After the optional word designator, you can add a sequence of one or more
|
||||
of the following modifiers, each preceded by a @key{:}.
|
||||
of the following modifiers, each preceded by a @samp{:}.
|
||||
|
||||
@table @code
|
||||
|
||||
@item h
|
||||
Remove a trailing pathname component, leaving only the head.
|
||||
|
||||
@item t
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
@item r
|
||||
Remove a trailing suffix of the form @samp{.}@var{suffix}, leaving the basename.
|
||||
Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
|
||||
the basename.
|
||||
|
||||
@item e
|
||||
Remove all but the trailing suffix.
|
||||
|
||||
@item t
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
@item p
|
||||
Print the new command but do not execute it.
|
||||
|
||||
|
|
@ -174,17 +280,17 @@ Print the new command but do not execute it.
|
|||
Quote the substituted words, escaping further substitutions.
|
||||
|
||||
@item x
|
||||
Quote the substituted words as with @code{q},
|
||||
Quote the substituted words as with @samp{q},
|
||||
but break into words at spaces, tabs, and newlines.
|
||||
@end ifset
|
||||
|
||||
@item s/old/new/
|
||||
@item s/@var{old}/@var{new}/
|
||||
Substitute @var{new} for the first occurrence of @var{old} in the
|
||||
event line. Any delimiter may be used in place of @key{/}.
|
||||
event line. Any delimiter may be used in place of @samp{/}.
|
||||
The delimiter may be quoted in @var{old} and @var{new}
|
||||
with a single backslash. If @key{&} appears in @var{new},
|
||||
with a single backslash. If @samp{&} appears in @var{new},
|
||||
it is replaced by @var{old}. A single backslash will quote
|
||||
the @key{&}. The final delimiter is optional if it is the last
|
||||
the @samp{&}. The final delimiter is optional if it is the last
|
||||
character on the input line.
|
||||
|
||||
@item &
|
||||
|
|
@ -192,7 +298,7 @@ Repeat the previous substitution.
|
|||
|
||||
@item g
|
||||
Cause changes to be applied over the entire event line. Used in
|
||||
conjunction with @code{s}, as in @code{gs/old/new/}, or with
|
||||
@code{&}.
|
||||
conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
|
||||
or with @samp{&}.
|
||||
|
||||
@end table
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,744 +0,0 @@
|
|||
This is Info file history.info, produced by Makeinfo-1.55 from the
|
||||
input file hist.texinfo.
|
||||
|
||||
This document describes the GNU History library, a programming tool
|
||||
that provides a consistent user interface for recalling lines of
|
||||
previously typed input.
|
||||
|
||||
Copyright (C) 1988, 1991 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of this
|
||||
manual provided the copyright notice and this permission notice pare
|
||||
preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of
|
||||
this manual under the conditions for verbatim copying, provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this
|
||||
manual into another language, under the above conditions for modified
|
||||
versions, except that this permission notice may be stated in a
|
||||
translation approved by the Foundation.
|
||||
|
||||
|
||||
File: history.info, Node: Top, Next: Using History Interactively, Prev: (DIR), Up: (DIR)
|
||||
|
||||
GNU History Library
|
||||
*******************
|
||||
|
||||
This document describes the GNU History library, a programming tool
|
||||
that provides a consistent user interface for recalling lines of
|
||||
previously typed input.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Using History Interactively:: GNU History User's Manual.
|
||||
* Programming with GNU History:: GNU History Programmer's Manual.
|
||||
* Concept Index:: Index of concepts described in this manual.
|
||||
* Function and Variable Index:: Index of externally visible functions
|
||||
and variables.
|
||||
|
||||
|
||||
File: history.info, Node: Using History Interactively, Next: Programming with GNU History, Prev: Top, Up: Top
|
||||
|
||||
Using History Interactively
|
||||
***************************
|
||||
|
||||
This chapter describes how to use the GNU History Library
|
||||
interactively, from a user's standpoint. It should be considered a
|
||||
user's guide. For information on using the GNU History Library in your
|
||||
own programs, *note Programming with GNU History::..
|
||||
|
||||
* Menu:
|
||||
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
|
||||
|
||||
File: history.info, Node: History Interaction, Up: Using History Interactively
|
||||
|
||||
History Interaction
|
||||
===================
|
||||
|
||||
The History library provides a history expansion feature that is
|
||||
similar to the history expansion provided by `csh'. The following text
|
||||
describes the syntax used to manipulate the history information.
|
||||
|
||||
History expansion takes place in two parts. The first is to
|
||||
determine which line from the previous history should be used during
|
||||
substitution. The second is to select portions of that line for
|
||||
inclusion into the current one. The line selected from the previous
|
||||
history is called the "event", and the portions of that line that are
|
||||
acted upon are called "words". The line is broken into words in the
|
||||
same fashion that Bash does, so that several English (or Unix) words
|
||||
surrounded by quotes are considered as one word.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Event Designators:: How to specify which history line to use.
|
||||
* Word Designators:: Specifying which words are of interest.
|
||||
* Modifiers:: Modifying the results of substitution.
|
||||
|
||||
|
||||
File: history.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
|
||||
|
||||
Event Designators
|
||||
-----------------
|
||||
|
||||
An event designator is a reference to a command line entry in the
|
||||
history list.
|
||||
|
||||
`!'
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, = or (.
|
||||
|
||||
`!!'
|
||||
Refer to the previous command. This is a synonym for `!-1'.
|
||||
|
||||
`!n'
|
||||
Refer to command line N.
|
||||
|
||||
`!-n'
|
||||
Refer to the command N lines back.
|
||||
|
||||
`!string'
|
||||
Refer to the most recent command starting with STRING.
|
||||
|
||||
`!?string'[`?']
|
||||
Refer to the most recent command containing STRING.
|
||||
|
||||
`!#'
|
||||
The entire command line typed so far.
|
||||
|
||||
`^string1^string2^'
|
||||
Quick Substitution. Repeat the last command, replacing STRING1
|
||||
with STRING2. Equivalent to `!!:s/string1/string2/'.
|
||||
|
||||
|
||||
File: history.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
|
||||
|
||||
Word Designators
|
||||
----------------
|
||||
|
||||
A : separates the event specification from the word designator. It
|
||||
can be omitted if the word designator begins with a ^, $, * or %.
|
||||
Words are numbered from the beginning of the line, with the first word
|
||||
being denoted by a 0 (zero).
|
||||
|
||||
`0 (zero)'
|
||||
The `0'th word. For many applications, this is the command word.
|
||||
|
||||
`n'
|
||||
The Nth word.
|
||||
|
||||
`^'
|
||||
The first argument; that is, word 1.
|
||||
|
||||
`$'
|
||||
The last argument.
|
||||
|
||||
`%'
|
||||
The word matched by the most recent `?string?' search.
|
||||
|
||||
`x-y'
|
||||
A range of words; `-Y' abbreviates `0-Y'.
|
||||
|
||||
`*'
|
||||
All of the words, except the `0'th. This is a synonym for `1-$'.
|
||||
It is not an error to use * if there is just one word in the event;
|
||||
the empty string is returned in that case.
|
||||
|
||||
`x*'
|
||||
Abbreviates `x-$'
|
||||
|
||||
`x-'
|
||||
Abbreviates `x-$' like `x*', but omits the last word.
|
||||
|
||||
|
||||
File: history.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
|
||||
|
||||
Modifiers
|
||||
---------
|
||||
|
||||
After the optional word designator, you can add a sequence of one or
|
||||
more of the following modifiers, each preceded by a :.
|
||||
|
||||
`h'
|
||||
Remove a trailing pathname component, leaving only the head.
|
||||
|
||||
`r'
|
||||
Remove a trailing suffix of the form `.'SUFFIX, leaving the
|
||||
basename.
|
||||
|
||||
`e'
|
||||
Remove all but the trailing suffix.
|
||||
|
||||
`t'
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
`p'
|
||||
Print the new command but do not execute it.
|
||||
|
||||
`s/old/new/'
|
||||
Substitute NEW for the first occurrence of OLD in the event line.
|
||||
Any delimiter may be used in place of /. The delimiter may be
|
||||
quoted in OLD and NEW with a single backslash. If & appears in
|
||||
NEW, it is replaced by OLD. A single backslash will quote the &.
|
||||
The final delimiter is optional if it is the last character on the
|
||||
input line.
|
||||
|
||||
`&'
|
||||
Repeat the previous substitution.
|
||||
|
||||
`g'
|
||||
Cause changes to be applied over the entire event line. Used in
|
||||
conjunction with `s', as in `gs/old/new/', or with `&'.
|
||||
|
||||
|
||||
File: history.info, Node: Programming with GNU History, Next: Concept Index, Prev: Using History Interactively, Up: Top
|
||||
|
||||
Programming with GNU History
|
||||
****************************
|
||||
|
||||
This chapter describes how to interface programs that you write with
|
||||
the GNU History Library. It should be considered a technical guide.
|
||||
For information on the interactive use of GNU History, *note Using
|
||||
History Interactively::..
|
||||
|
||||
* Menu:
|
||||
|
||||
* Introduction to History:: What is the GNU History library for?
|
||||
* History Storage:: How information is stored.
|
||||
* History Functions:: Functions that you can use.
|
||||
* History Variables:: Variables that control behaviour.
|
||||
* History Programming Example:: Example of using the GNU History Library.
|
||||
|
||||
|
||||
File: history.info, Node: Introduction to History, Next: History Storage, Up: Programming with GNU History
|
||||
|
||||
Introduction to History
|
||||
=======================
|
||||
|
||||
Many programs read input from the user a line at a time. The GNU
|
||||
History library is able to keep track of those lines, associate
|
||||
arbitrary data with each line, and utilize information from previous
|
||||
lines in composing new ones.
|
||||
|
||||
The programmer using the History library has available functions for
|
||||
remembering lines on a history list, associating arbitrary data with a
|
||||
line, removing lines from the list, searching through the list for a
|
||||
line containing an arbitrary text string, and referencing any line in
|
||||
the list directly. In addition, a history "expansion" function is
|
||||
available which provides for a consistent user interface across
|
||||
different programs.
|
||||
|
||||
The user using programs written with the History library has the
|
||||
benefit of a consistent user interface with a set of well-known
|
||||
commands for manipulating the text of previous lines and using that text
|
||||
in new commands. The basic history manipulation commands are similar to
|
||||
the history substitution provided by `csh'.
|
||||
|
||||
If the programmer desires, he can use the Readline library, which
|
||||
includes some history manipulation by default, and has the added
|
||||
advantage of command line editing.
|
||||
|
||||
|
||||
File: history.info, Node: History Storage, Next: History Functions, Prev: Introduction to History, Up: Programming with GNU History
|
||||
|
||||
History Storage
|
||||
===============
|
||||
|
||||
The history list is an array of history entries. A history entry is
|
||||
declared as follows:
|
||||
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
The history list itself might therefore be declared as
|
||||
|
||||
HIST_ENTRY **the_history_list;
|
||||
|
||||
The state of the History library is encapsulated into a single
|
||||
structure:
|
||||
|
||||
/* A structure used to pass the current state of the history stuff around. */
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
int flags;
|
||||
} HISTORY_STATE;
|
||||
|
||||
If the flags member includes `HS_STIFLED', the history has been
|
||||
stifled.
|
||||
|
||||
|
||||
File: history.info, Node: History Functions, Next: History Variables, Prev: History Storage, Up: Programming with GNU History
|
||||
|
||||
History Functions
|
||||
=================
|
||||
|
||||
This section describes the calling sequence for the various functions
|
||||
present in GNU History.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Initializing History and State Management:: Functions to call when you
|
||||
want to use history in a
|
||||
program.
|
||||
* History List Management:: Functions used to manage the list
|
||||
of history entries.
|
||||
* Information About the History List:: Functions returning information about
|
||||
the history list.
|
||||
* Moving Around the History List:: Functions used to change the position
|
||||
in the history list.
|
||||
* Searching the History List:: Functions to search the history list
|
||||
for entries containing a string.
|
||||
* Managing the History File:: Functions that read and write a file
|
||||
containing the history list.
|
||||
* History Expansion:: Functions to perform csh-like history
|
||||
expansion.
|
||||
|
||||
|
||||
File: history.info, Node: Initializing History and State Management, Next: History List Management, Up: History Functions
|
||||
|
||||
Initializing History and State Management
|
||||
-----------------------------------------
|
||||
|
||||
This section describes functions used to initialize and manage the
|
||||
state of the History library when you want to use the history functions
|
||||
in your program.
|
||||
|
||||
- Function: void using_history ()
|
||||
Begin a session in which the history functions might be used. This
|
||||
initializes the interactive variables.
|
||||
|
||||
- Function: HISTORY_STATE * history_get_history_state ()
|
||||
Return a structure describing the current state of the input
|
||||
history.
|
||||
|
||||
- Function: void history_set_history_state (HISTORY_STATE *state)
|
||||
Set the state of the history list according to STATE.
|
||||
|
||||
|
||||
File: history.info, Node: History List Management, Next: Information About the History List, Prev: Initializing History and State Management, Up: History Functions
|
||||
|
||||
History List Management
|
||||
-----------------------
|
||||
|
||||
These functions manage individual entries on the history list, or set
|
||||
parameters managing the list itself.
|
||||
|
||||
- Function: void add_history (char *string)
|
||||
Place STRING at the end of the history list. The associated data
|
||||
field (if any) is set to `NULL'.
|
||||
|
||||
- Function: HIST_ENTRY * remove_history (int which)
|
||||
Remove history entry at offset WHICH from the history. The
|
||||
removed element is returned so you can free the line, data, and
|
||||
containing structure.
|
||||
|
||||
- Function: HIST_ENTRY * replace_history_entry (int which, char *line,
|
||||
char *data)
|
||||
Make the history entry at offset WHICH have LINE and DATA. This
|
||||
returns the old entry so you can dispose of the data. In the case
|
||||
of an invalid WHICH, a `NULL' pointer is returned.
|
||||
|
||||
- Function: void stifle_history (int max)
|
||||
Stifle the history list, remembering only the last MAX entries.
|
||||
|
||||
- Function: int unstifle_history ()
|
||||
Stop stifling the history. This returns the previous amount the
|
||||
history was stifled. The value is positive if the history was
|
||||
stifled, negative if it wasn't.
|
||||
|
||||
- Function: int history_is_stifled ()
|
||||
Returns non-zero if the history is stifled, zero if it is not.
|
||||
|
||||
|
||||
File: history.info, Node: Information About the History List, Next: Moving Around the History List, Prev: History List Management, Up: History Functions
|
||||
|
||||
Information About the History List
|
||||
----------------------------------
|
||||
|
||||
These functions return information about the entire history list or
|
||||
individual list entries.
|
||||
|
||||
- Function: HIST_ENTRY ** history_list ()
|
||||
Return a `NULL' terminated array of `HIST_ENTRY' which is the
|
||||
current input history. Element 0 of this list is the beginning of
|
||||
time. If there is no history, return `NULL'.
|
||||
|
||||
- Function: int where_history ()
|
||||
Returns the offset of the current history element.
|
||||
|
||||
- Function: HIST_ENTRY * current_history ()
|
||||
Return the history entry at the current position, as determined by
|
||||
`where_history ()'. If there is no entry there, return a `NULL'
|
||||
pointer.
|
||||
|
||||
- Function: HIST_ENTRY * history_get (int offset)
|
||||
Return the history entry at position OFFSET, starting from
|
||||
`history_base'. If there is no entry there, or if OFFSET is
|
||||
greater than the history length, return a `NULL' pointer.
|
||||
|
||||
- Function: int history_total_bytes ()
|
||||
Return the number of bytes that the primary history entries are
|
||||
using. This function returns the sum of the lengths of all the
|
||||
lines in the history.
|
||||
|
||||
|
||||
File: history.info, Node: Moving Around the History List, Next: Searching the History List, Prev: Information About the History List, Up: History Functions
|
||||
|
||||
Moving Around the History List
|
||||
------------------------------
|
||||
|
||||
These functions allow the current index into the history list to be
|
||||
set or changed.
|
||||
|
||||
- Function: int history_set_pos (int pos)
|
||||
Set the position in the history list to POS, an absolute index
|
||||
into the list.
|
||||
|
||||
- Function: HIST_ENTRY * previous_history ()
|
||||
Back up the current history offset to the previous history entry,
|
||||
and return a pointer to that entry. If there is no previous
|
||||
entry, return a `NULL' pointer.
|
||||
|
||||
- Function: HIST_ENTRY * next_history ()
|
||||
Move the current history offset forward to the next history entry,
|
||||
and return the a pointer to that entry. If there is no next
|
||||
entry, return a `NULL' pointer.
|
||||
|
||||
|
||||
File: history.info, Node: Searching the History List, Next: Managing the History File, Prev: Moving Around the History List, Up: History Functions
|
||||
|
||||
Searching the History List
|
||||
--------------------------
|
||||
|
||||
These functions allow searching of the history list for entries
|
||||
containing a specific string. Searching may be performed both forward
|
||||
and backward from the current history position. The search may be
|
||||
"anchored", meaning that the string must match at the beginning of the
|
||||
history entry.
|
||||
|
||||
- Function: int history_search (char *string, int direction)
|
||||
Search the history for STRING, starting at the current history
|
||||
offset. If DIRECTION < 0, then the search is through previous
|
||||
entries, else through subsequent. If STRING is found, then the
|
||||
current history index is set to that history entry, and the value
|
||||
returned is the offset in the line of the entry where STRING was
|
||||
found. Otherwise, nothing is changed, and a -1 is returned.
|
||||
|
||||
- Function: int history_search_prefix (char *string, int direction)
|
||||
Search the history for STRING, starting at the current history
|
||||
offset. The search is anchored: matching lines must begin with
|
||||
STRING. If DIRECTION < 0, then the search is through previous
|
||||
entries, else through subsequent. If STRING is found, then the
|
||||
current history index is set to that entry, and the return value
|
||||
is 0. Otherwise, nothing is changed, and a -1 is returned.
|
||||
|
||||
- Function: int history_search_pos (char *string, int direction, int
|
||||
pos)
|
||||
Search for STRING in the history list, starting at POS, an
|
||||
absolute index into the list. If DIRECTION is negative, the search
|
||||
proceeds backward from POS, otherwise forward. Returns the
|
||||
absolute index of the history element where STRING was found, or
|
||||
-1 otherwise.
|
||||
|
||||
|
||||
File: history.info, Node: Managing the History File, Next: History Expansion, Prev: Searching the History List, Up: History Functions
|
||||
|
||||
Managing the History File
|
||||
-------------------------
|
||||
|
||||
The History library can read the history from and write it to a file.
|
||||
This section documents the functions for managing a history file.
|
||||
|
||||
- Function: int read_history (char *filename)
|
||||
Add the contents of FILENAME to the history list, a line at a
|
||||
time. If FILENAME is `NULL', then read from `~/.history'.
|
||||
Returns 0 if successful, or errno if not.
|
||||
|
||||
- Function: int read_history_range (char *filename, int from, int to)
|
||||
Read a range of lines from FILENAME, adding them to the history
|
||||
list. Start reading at line FROM and end at TO. If FROM is zero,
|
||||
start at the beginning. If TO is less than FROM, then read until
|
||||
the end of the file. If FILENAME is `NULL', then read from
|
||||
`~/.history'. Returns 0 if successful, or `errno' if not.
|
||||
|
||||
- Function: int write_history (char *filename)
|
||||
Write the current history to FILENAME, overwriting FILENAME if
|
||||
necessary. If FILENAME is `NULL', then write the history list to
|
||||
`~/.history'. Values returned are as in `read_history ()'.
|
||||
|
||||
- Function: int append_history (int nelements, char *filename)
|
||||
Append the last NELEMENTS of the history list to FILENAME.
|
||||
|
||||
- Function: int history_truncate_file (char *filename, int nlines)
|
||||
Truncate the history file FILENAME, leaving only the last NLINES
|
||||
lines.
|
||||
|
||||
|
||||
File: history.info, Node: History Expansion, Prev: Managing the History File, Up: History Functions
|
||||
|
||||
History Expansion
|
||||
-----------------
|
||||
|
||||
These functions implement `csh'-like history expansion.
|
||||
|
||||
- Function: int history_expand (char *string, char **output)
|
||||
Expand STRING, placing the result into OUTPUT, a pointer to a
|
||||
string (*note History Interaction::.). Returns:
|
||||
`0'
|
||||
If no expansions took place (or, if the only change in the
|
||||
text was the de-slashifying of the history expansion
|
||||
character);
|
||||
|
||||
`1'
|
||||
if expansions did take place;
|
||||
|
||||
`-1'
|
||||
if there was an error in expansion;
|
||||
|
||||
`2'
|
||||
if the returned line should only be displayed, but not
|
||||
executed, as with the `:p' modifier (*note Modifiers::.).
|
||||
|
||||
If an error ocurred in expansion, then OUTPUT contains a
|
||||
descriptive error message.
|
||||
|
||||
- Function: char * history_arg_extract (int first, int last, char
|
||||
*string)
|
||||
Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in Bash.
|
||||
|
||||
- Function: char * get_history_event (char *string, int *cindex, int
|
||||
qchar)
|
||||
Returns the text of the history event beginning at STRING +
|
||||
*CINDEX. *CINDEX is modified to point to after the event
|
||||
specifier. At function entry, CINDEX points to the index into
|
||||
STRING where the history event specification begins. QCHAR is a
|
||||
character that is allowed to end the event specification in
|
||||
addition to the "normal" terminating characters.
|
||||
|
||||
- Function: char ** history_tokenize (char *string)
|
||||
Return an array of tokens parsed out of STRING, much as the shell
|
||||
might. The tokens are split on white space and on the characters
|
||||
`()<>;&|$', and shell quoting conventions are obeyed.
|
||||
|
||||
|
||||
File: history.info, Node: History Variables, Next: History Programming Example, Prev: History Functions, Up: Programming with GNU History
|
||||
|
||||
History Variables
|
||||
=================
|
||||
|
||||
This section describes the externally visible variables exported by
|
||||
the GNU History Library.
|
||||
|
||||
- Variable: int history_base
|
||||
The logical offset of the first entry in the history list.
|
||||
|
||||
- Variable: int history_length
|
||||
The number of entries currently stored in the history list.
|
||||
|
||||
- Variable: int max_input_history
|
||||
The maximum number of history entries. This must be changed using
|
||||
`stifle_history ()'.
|
||||
|
||||
- Variable: char history_expansion_char
|
||||
The character that starts a history event. The default is `!'.
|
||||
|
||||
- Variable: char history_subst_char
|
||||
The character that invokes word substitution if found at the start
|
||||
of a line. The default is `^'.
|
||||
|
||||
- Variable: char history_comment_char
|
||||
During tokenization, if this character is seen as the first
|
||||
character of a word, then it and all subsequent characters up to a
|
||||
newline are ignored, suppressing history expansion for the
|
||||
remainder of the line. This is disabled by default.
|
||||
|
||||
- Variable: char * history_no_expand_chars
|
||||
The list of characters which inhibit history expansion if found
|
||||
immediately following HISTORY_EXPANSION_CHAR. The default is
|
||||
whitespace and `='.
|
||||
|
||||
|
||||
File: history.info, Node: History Programming Example, Prev: History Variables, Up: Programming with GNU History
|
||||
|
||||
History Programming Example
|
||||
===========================
|
||||
|
||||
The following program demonstrates simple use of the GNU History
|
||||
Library.
|
||||
|
||||
main ()
|
||||
{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
||||
line[0] = 0;
|
||||
|
||||
using_history ();
|
||||
while (!done)
|
||||
{
|
||||
printf ("history$ ");
|
||||
fflush (stdout);
|
||||
t = fgets (line, sizeof (line) - 1, stdin);
|
||||
if (t && *t)
|
||||
{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
}
|
||||
|
||||
if (!t)
|
||||
strcpy (line, "quit");
|
||||
|
||||
if (line[0])
|
||||
{
|
||||
char *expansion;
|
||||
int result;
|
||||
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
|
||||
if (result < 0 || result == 2)
|
||||
{
|
||||
free (expansion);
|
||||
continue;
|
||||
}
|
||||
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
}
|
||||
|
||||
if (strcmp (line, "quit") == 0)
|
||||
done = 1;
|
||||
else if (strcmp (line, "save") == 0)
|
||||
write_history ("history_file");
|
||||
else if (strcmp (line, "read") == 0)
|
||||
read_history ("history_file");
|
||||
else if (strcmp (line, "list") == 0)
|
||||
{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
printf ("%d: %s\n", i + history_base, the_list[i]->line);
|
||||
}
|
||||
else if (strncmp (line, "delete", 6) == 0)
|
||||
{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File: history.info, Node: Concept Index, Next: Function and Variable Index, Prev: Programming with GNU History, Up: Top
|
||||
|
||||
Concept Index
|
||||
*************
|
||||
|
||||
* Menu:
|
||||
|
||||
* anchored search: Searching the History List.
|
||||
* event designators: Event Designators.
|
||||
* expansion: History Interaction.
|
||||
* history events: Event Designators.
|
||||
* History Searching: Searching the History List.
|
||||
|
||||
|
||||
File: history.info, Node: Function and Variable Index, Prev: Concept Index, Up: Top
|
||||
|
||||
Function and Variable Index
|
||||
***************************
|
||||
|
||||
* Menu:
|
||||
|
||||
* add_history: History List Management.
|
||||
* append_history: Managing the History File.
|
||||
* current_history: Information About the History List.
|
||||
* get_history_event: History Expansion.
|
||||
* history_arg_extract: History Expansion.
|
||||
* history_base: History Variables.
|
||||
* history_comment_char: History Variables.
|
||||
* history_expand: History Expansion.
|
||||
* history_expansion_char: History Variables.
|
||||
* history_get: Information About the History List.
|
||||
* history_get_history_state: Initializing History and State Management.
|
||||
* history_is_stifled: History List Management.
|
||||
* history_length: History Variables.
|
||||
* history_list: Information About the History List.
|
||||
* history_no_expand_chars: History Variables.
|
||||
* history_search: Searching the History List.
|
||||
* history_search_pos: Searching the History List.
|
||||
* history_search_prefix: Searching the History List.
|
||||
* history_set_history_state: Initializing History and State Management.
|
||||
* history_set_pos: Moving Around the History List.
|
||||
* history_subst_char: History Variables.
|
||||
* history_tokenize: History Expansion.
|
||||
* history_total_bytes: Information About the History List.
|
||||
* history_truncate_file: Managing the History File.
|
||||
* max_input_history: History Variables.
|
||||
* next_history: Moving Around the History List.
|
||||
* previous_history: Moving Around the History List.
|
||||
* read_history: Managing the History File.
|
||||
* read_history_range: Managing the History File.
|
||||
* remove_history: History List Management.
|
||||
* replace_history_entry: History List Management.
|
||||
* stifle_history: History List Management.
|
||||
* unstifle_history: History List Management.
|
||||
* using_history: Initializing History and State Management.
|
||||
* where_history: Information About the History List.
|
||||
* write_history: Managing the History File.
|
||||
|
||||
|
||||
|
||||
Tag Table:
|
||||
Node: Top975
|
||||
Node: Using History Interactively1569
|
||||
Node: History Interaction2077
|
||||
Node: Event Designators3122
|
||||
Node: Word Designators3952
|
||||
Node: Modifiers4936
|
||||
Node: Programming with GNU History6065
|
||||
Node: Introduction to History6791
|
||||
Node: History Storage8112
|
||||
Node: History Functions9205
|
||||
Node: Initializing History and State Management10176
|
||||
Node: History List Management10968
|
||||
Node: Information About the History List12396
|
||||
Node: Moving Around the History List13702
|
||||
Node: Searching the History List14587
|
||||
Node: Managing the History File16419
|
||||
Node: History Expansion17925
|
||||
Node: History Variables19769
|
||||
Node: History Programming Example21138
|
||||
Node: Concept Index23742
|
||||
Node: Function and Variable Index24223
|
||||
|
||||
End Tag Table
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,13 +7,13 @@
|
|||
@setchapternewpage odd
|
||||
|
||||
@ignore
|
||||
last change: Thu Jul 21 16:02:40 EDT 1994
|
||||
last change: Thu Mar 21 16:06:39 EST 1996
|
||||
@end ignore
|
||||
|
||||
@set EDITION 2.0
|
||||
@set VERSION 2.0
|
||||
@set UPDATED 21 July 1994
|
||||
@set UPDATE-MONTH July 1994
|
||||
@set EDITION 2.1
|
||||
@set VERSION 2.1
|
||||
@set UPDATED 21 March 1996
|
||||
@set UPDATE-MONTH March 1996
|
||||
|
||||
@ifinfo
|
||||
This document describes the GNU Readline Library, a utility which aids
|
||||
|
|
@ -45,7 +45,6 @@ by the Foundation.
|
|||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@sp 10
|
||||
@title GNU Readline Library
|
||||
@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATE-MONTH}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ This document describes the GNU Readline Library, a utility for aiding
|
|||
in the consitency of user interface across discrete programs that need
|
||||
to provide a command line interface.
|
||||
|
||||
Copyright (C) 1988, 1994 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1994, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
|
|
@ -273,6 +273,10 @@ The prompt Readline uses. This is set from the argument to
|
|||
@code{readline ()}, and should not be assigned to directly.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_library_version
|
||||
The version number of this revision of the library.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_terminal_name
|
||||
The terminal type, used for initialization.
|
||||
@end deftypevar
|
||||
|
|
@ -301,6 +305,30 @@ If non-zero, this is the address of a function to call periodically
|
|||
when readline is waiting for terminal input.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Function *} rl_getc_function
|
||||
If non-zero, @code{readline} will call indirectly through this pointer
|
||||
to get a character from the input stream. By default, it is set to
|
||||
@code{rl_getc}, the default @code{readline} character input function
|
||||
(@pxref{Utility Functions}).
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Function *} rl_redisplay_function
|
||||
If non-zero, @code{readline} will call indirectly through this pointer
|
||||
to update the display with the current contents of the editing buffer.
|
||||
By default, it is set to @code{rl_redisplay}, the default @code{readline}
|
||||
redisplay function (@pxref{Redisplay}).
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Keymap} rl_executing_keymap
|
||||
This variable is set to the keymap (@pxref{Keymaps}) in which the
|
||||
currently executing readline function was found.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Keymap} rl_binding_keymap
|
||||
This variable is set to the keymap (@pxref{Keymaps}) in which the
|
||||
last key binding occurred.
|
||||
@end deftypevar
|
||||
|
||||
@node Readline Convenience Functions
|
||||
@section Readline Convenience Functions
|
||||
|
||||
|
|
@ -314,6 +342,7 @@ when readline is waiting for terminal input.
|
|||
* Redisplay:: Functions to control line display.
|
||||
* Modifying Text:: Functions to modify @code{rl_line_buffer}.
|
||||
* Utility Functions:: Generally useful functions and hooks.
|
||||
* Alternate Interface:: Using Readline in a `callback' fashion.
|
||||
@end menu
|
||||
|
||||
@node Function Naming
|
||||
|
|
@ -611,6 +640,10 @@ the input stream via @var{pending input} (@pxref{Readline Variables})
|
|||
and @code{rl_stuff_char ()}, macros, and characters read from the keyboard.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_getc (FILE *)
|
||||
Return the next character available from the keyboard.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_stuff_char (int c)
|
||||
Insert @var{c} into the Readline input stream. It will be "read"
|
||||
before Readline attempts to read characters from the terminal with
|
||||
|
|
@ -666,6 +699,37 @@ lowercase character.
|
|||
If @var{c} is a number, return the value it represents.
|
||||
@end deftypefun
|
||||
|
||||
@node Alternate Interface
|
||||
@subsection Alternate Interface
|
||||
|
||||
An alternate interface is available to plain @code{readline()}. Some
|
||||
applications need to interleave keyboard I/O with file, device, or
|
||||
window system I/O, typically by using a main loop to @code{select()}
|
||||
on various file descriptors. To accomodate this need, readline can
|
||||
also be invoked as a `callback' function from an event loop. There
|
||||
are functions available to make this easy.
|
||||
|
||||
@deftypefun void rl_callback_handler_install (char *prompt, Vfunction *lhandler)
|
||||
Set up the terminal for readline I/O and display the initial
|
||||
expanded value of @var{prompt}. Save the value of @var{lhandler} to
|
||||
use as a callback when a complete line of input has been entered.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_callback_read_char ()
|
||||
Whenever an application determines that keyboard input is available, it
|
||||
should call @code{rl_callback_read_char()}, which will read the next
|
||||
character from the current input source. If that character completes the
|
||||
line, @code{rl_callback_read_char} will invoke the @var{lhandler}
|
||||
function saved by @code{rl_callback_handler_install} to process the
|
||||
line. @code{EOF} is indicated by calling @var{lhandler} with a
|
||||
@code{NULL} line.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_callback_handler_remove ()
|
||||
Restore the terminal to its initial state and remove the line handler.
|
||||
This may be called from within a callback as well as independently.
|
||||
@end deftypefun
|
||||
|
||||
@subsection An Example
|
||||
|
||||
Here is a function which changes lowercase characters to their uppercase
|
||||
|
|
@ -894,6 +958,40 @@ returns @code{NULL}, or if this variable is set to @code{NULL}, then
|
|||
array of strings returned will be used.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {CPFunction *} rl_filename_quoting_function
|
||||
A pointer to a function that will quote a filename in an application-
|
||||
specific fashion. This is called if filename completion is being
|
||||
attempted and one of the characters in @code{rl_filename_quote_characters}
|
||||
appears in a completed filename. The function is called with
|
||||
@var{text}, @var{match_type}, and @var{quote_pointer}. The @var{text}
|
||||
is the filename to be quoted. The @var{match_type} is either
|
||||
@code{SINGLE_MATCH}, if there is only one completion match, or
|
||||
@code{MULT_MATCH}. Some functions use this to decide whether or not to
|
||||
insert a closing quote character. The @var{quote_pointer} is a pointer
|
||||
to any opening quote character the user typed. Some functions choose
|
||||
to reset this character.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {CPFunction *} rl_filename_dequoting_function
|
||||
A pointer to a function that will remove application-specific quoting
|
||||
characters from a filename before completion is attempted, so those
|
||||
characters do not interfere with matching the text against names in
|
||||
the filesystem. It is called with @var{text}, the text of the word
|
||||
to be dequoted, and @var{quote_char}, which is the quoting character
|
||||
that delimits the filename (usually @samp{'} or @samp{"}). If
|
||||
@var{quote_char} is zero, the filename was not in an embedded string.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Function *} rl_char_is_quoted_p
|
||||
A pointer to a function to call that determines whether or not a specific
|
||||
character in the line buffer is quoted, according to whatever quoting
|
||||
mechanism the program calling readline uses. The function is called with
|
||||
two arguments: @var{text}, the text of the line, and @var{index}, the
|
||||
index of the character in the line. It is used to decide whether a
|
||||
character found in @code{rl_completer_word_break_characters} should be
|
||||
used to break words for the completer.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int rl_completion_query_items
|
||||
Up to this many items will be displayed in response to a
|
||||
possible-completions call. After that, we ask the user if she is sure
|
||||
|
|
@ -907,6 +1005,10 @@ which break words for completion in Bash, i.e.,
|
|||
@code{" \t\n\"\\'`@@$><=;|&@{("}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_basic_quote_characters
|
||||
List of quote characters which can cause a word break.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_completer_word_break_characters
|
||||
The list of characters that signal a break between words for
|
||||
@code{rl_complete_internal ()}. The default list is the value of
|
||||
|
|
@ -920,6 +1022,11 @@ Completion occurs on the entire substring, and within the substring
|
|||
unless they also appear within this list.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_filename_quote_characters
|
||||
A list of characters that cause a filename to be quoted by the completer
|
||||
when they appear in a completed filename. The default is empty.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {char *} rl_special_prefixes
|
||||
The list of characters that are word break characters, but should be
|
||||
left in @var{text} when it is passed to the completion function.
|
||||
|
|
@ -928,6 +1035,16 @@ For instance, Bash sets this variable to "$@@" so that it can complete
|
|||
shell variables and hostnames.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {int} rl_completion_append_character
|
||||
When a single completion alternative matches at the end of the command
|
||||
line, this character is appended to the inserted completion text. The
|
||||
default is a space character (@samp{ }). Setting this to the null
|
||||
character (@samp{\0}) prevents anything being appended automatically.
|
||||
This can be changed in custom completion functions to
|
||||
provide the ``most sensible word separator character'' according to
|
||||
an application-specific command line syntax specification.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int rl_ignore_completion_duplicates
|
||||
If non-zero, then disallow duplicates in the matches. Default is 1.
|
||||
@end deftypevar
|
||||
|
|
@ -945,9 +1062,15 @@ characters.
|
|||
Non-zero means that the results of the matches are to be quoted using
|
||||
double quotes (or an application-specific quoting mechanism) if the
|
||||
completed filename contains any characters in
|
||||
@code{rl_completer_word_break_chars}. This is @emph{always} non-zero
|
||||
@code{rl_filename_quote_chars}. This is @emph{always} non-zero
|
||||
on entry, and can only be changed within a completion entry generator
|
||||
function.
|
||||
function. The quoting is effected via a call to the function pointed to
|
||||
by @code{rl_filename_quoting_function}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int rl_inhibit_completion
|
||||
If this variable is non-zero, completion is inhibited. The completion
|
||||
character will be inserted as any other bound to @code{self-insert}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Function *} rl_ignore_some_completions_function
|
||||
|
|
@ -1174,10 +1297,11 @@ initialize_readline ()
|
|||
rl_attempted_completion_function = (CPPFunction *)fileman_completion;
|
||||
@}
|
||||
|
||||
/* Attempt to complete on the contents of TEXT. START and END show the
|
||||
region of TEXT that contains the word to complete. We can use the
|
||||
entire line in case we want to do some simple parsing. Return the
|
||||
array of matches, or NULL if there aren't any. */
|
||||
/* Attempt to complete on the contents of TEXT. START and END bound the
|
||||
region of rl_line_buffer that contains the word to complete. TEXT is
|
||||
the word to complete. We can use the entire contents of rl_line_buffer
|
||||
in case we want to do some simple parsing. Return the array of matches,
|
||||
or NULL if there aren't any. */
|
||||
char **
|
||||
fileman_completion (text, start, end)
|
||||
char *text;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use these features. There is a document entitled "readline.texinfo"
|
|||
which contains both end-user and programmer documentation for the GNU
|
||||
Readline Library.
|
||||
|
||||
Copyright (C) 1988 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1991, 1993, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Authored by Brian Fox and Chet Ramey.
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ into another language, under the above conditions for modified versions.
|
|||
@node Command Line Editing
|
||||
@chapter Command Line Editing
|
||||
|
||||
This chapter describes the basic features of the GNU
|
||||
This chapter describes the basic features of the @sc{GNU}
|
||||
command line editing interface.
|
||||
|
||||
@menu
|
||||
|
|
@ -59,11 +59,12 @@ The following paragraphs describe the notation used to represent
|
|||
keystrokes.
|
||||
|
||||
The text @key{C-k} is read as `Control-K' and describes the character
|
||||
produced when the Control key is depressed and the @key{k} key is struck.
|
||||
produced when the @key{k} key is pressed while the Control key
|
||||
is depressed.
|
||||
|
||||
The text @key{M-k} is read as `Meta-K' and describes the character
|
||||
produced when the meta key (if you have one) is depressed, and the @key{k}
|
||||
key is struck. If you do not have a meta key, the identical keystroke
|
||||
key is pressed. If you do not have a meta key, the identical keystroke
|
||||
can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
|
||||
Either process is known as @dfn{metafying} the @key{k} key.
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ character produced by @dfn{metafying} @key{C-k}.
|
|||
In addition, several keys have their own names. Specifically,
|
||||
@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
|
||||
stand for themselves when seen in this text, or in an init file
|
||||
(@pxref{Readline Init File}, for more info).
|
||||
(@pxref{Readline Init File}).
|
||||
|
||||
@node Readline Interaction
|
||||
@section Readline Interaction
|
||||
|
|
@ -95,10 +96,14 @@ regardless of the location of the cursor within the line.
|
|||
* Readline Movement Commands:: Moving about the input line.
|
||||
* Readline Killing Commands:: How to delete text, and how to get it back!
|
||||
* Readline Arguments:: Giving numeric arguments to commands.
|
||||
@end menu
|
||||
* Searching:: Searching through previous lines.
|
||||
@end menu
|
||||
|
||||
@node Readline Bare Essentials
|
||||
@subsection Readline Bare Essentials
|
||||
@cindex notation, readline
|
||||
@cindex command editing
|
||||
@cindex editing command lines
|
||||
|
||||
In order to enter characters into the line, simply type them. The typed
|
||||
character appears where the cursor was, and then the cursor moves one
|
||||
|
|
@ -164,8 +169,8 @@ operate on characters while meta keystrokes operate on words.
|
|||
@node Readline Killing Commands
|
||||
@subsection Readline Killing Commands
|
||||
|
||||
@cindex Killing text
|
||||
@cindex Yanking text
|
||||
@cindex killing text
|
||||
@cindex yanking text
|
||||
|
||||
@dfn{Killing} text means to delete the text from the line, but to save
|
||||
it away for later use, usually by @dfn{yanking} (re-inserting)
|
||||
|
|
@ -180,7 +185,7 @@ that when you yank it back, you get it all. The kill
|
|||
ring is not line specific; the text that you killed on a previously
|
||||
typed line is available to be yanked back later, when you are typing
|
||||
another line.
|
||||
@cindex Kill ring
|
||||
@cindex kill ring
|
||||
|
||||
Here is the list of commands for killing text.
|
||||
|
||||
|
|
@ -222,24 +227,59 @@ argument acts as a repeat count, other times it is the @i{sign} of the
|
|||
argument that is significant. If you pass a negative argument to a
|
||||
command which normally acts in a forward direction, that command will
|
||||
act in a backward direction. For example, to kill text back to the
|
||||
start of the line, you might type @key{M--} @key{C-k}.
|
||||
start of the line, you might type @w{@kbd{M-- C-k}}.
|
||||
|
||||
The general way to pass numeric arguments to a command is to type meta
|
||||
digits before the command. If the first `digit' you type is a minus
|
||||
sign (@key{-}), then the sign of the argument will be negative. Once
|
||||
you have typed one meta digit to get the argument started, you can type
|
||||
the remainder of the digits, and then the command. For example, to give
|
||||
the @key{C-d} command an argument of 10, you could type @key{M-1 0 C-d}.
|
||||
the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}.
|
||||
|
||||
@node Searching
|
||||
@subsection Searching for Commands in the History
|
||||
|
||||
Readline provides commands for searching through the command history
|
||||
@ifset BashFeatures
|
||||
(@pxref{Bash History Facilities})
|
||||
@end ifset
|
||||
for lines containing a specified string.
|
||||
There are two search modes: @var{incremental} and @var{non-incremental}.
|
||||
|
||||
Incremental searches begin before the user has finished typing the
|
||||
search string.
|
||||
As each character of the search string is typed, readline displays
|
||||
the next entry from the history matching the string typed so far.
|
||||
An incremental search requires only as many characters as needed to
|
||||
find the desired history entry.
|
||||
The Escape character is used to terminate an incremental search.
|
||||
Control-J will also terminate the search.
|
||||
Control-G will abort an incremental search and restore the original
|
||||
line.
|
||||
When the search is terminated, the history entry containing the
|
||||
search string becomes the current line.
|
||||
To find other matching entries in the history list, type Control-S or
|
||||
Control-R as appropriate.
|
||||
This will search backward or forward in the history for the next
|
||||
entry matching the search string typed so far.
|
||||
Any other key sequence bound to a readline command will terminate
|
||||
the search and execute that command.
|
||||
For instance, a @code{newline} will terminate the search and accept
|
||||
the line, thereby executing the command from the history list.
|
||||
|
||||
Non-incremental searches read the entire search string before starting
|
||||
to search for matching history lines. The search string may be
|
||||
typed by the user or part of the contents of the current line.
|
||||
|
||||
@node Readline Init File
|
||||
@section Readline Init File
|
||||
@cindex initialization file, readline
|
||||
|
||||
Although the Readline library comes with a set of Emacs-like
|
||||
Although the Readline library comes with a set of @code{emacs}-like
|
||||
keybindings installed by default,
|
||||
it is possible that you would like to use a different set
|
||||
of keybindings. You can customize programs that use Readline by putting
|
||||
commands in an @dfn{init} file in your home directory. The name of this
|
||||
commands in an @dfn{inputrc} file in your home directory. The name of this
|
||||
@ifset BashFeatures
|
||||
file is taken from the value of the shell variable @code{INPUTRC}. If
|
||||
@end ifset
|
||||
|
|
@ -255,17 +295,20 @@ In addition, the @code{C-x C-r} command re-reads this init file, thus
|
|||
incorporating any changes that you might have made to it.
|
||||
|
||||
@menu
|
||||
* Readline Init Syntax:: Syntax for the commands in the inputrc file.
|
||||
* Readline Init File Syntax:: Syntax for the commands in the inputrc file.
|
||||
|
||||
* Conditional Init Constructs:: Conditional key bindings in the inputrc file.
|
||||
|
||||
* Sample Init File:: An example inputrc file.
|
||||
@end menu
|
||||
|
||||
@node Readline Init Syntax
|
||||
@subsection Readline Init Syntax
|
||||
@node Readline Init File Syntax
|
||||
@subsection Readline Init File Syntax
|
||||
|
||||
There are only a few basic constructs allowed in the
|
||||
Readline init file. Blank lines are ignored.
|
||||
Lines beginning with a @key{#} are comments.
|
||||
Lines beginning with a @key{$} indicate conditional
|
||||
Lines beginning with a @samp{#} are comments.
|
||||
Lines beginning with a @samp{$} indicate conditional
|
||||
constructs (@pxref{Conditional Init Constructs}). Other lines
|
||||
denote variable settings and key bindings.
|
||||
|
||||
|
|
@ -284,61 +327,20 @@ so few, in fact, that we just list them here:
|
|||
|
||||
@table @code
|
||||
|
||||
@item editing-mode
|
||||
@vindex editing-mode
|
||||
The @code{editing-mode} variable controls which editing mode you are
|
||||
using. By default, Readline starts up in Emacs editing mode, where
|
||||
the keystrokes are most similar to Emacs. This variable can be
|
||||
set to either @code{emacs} or @code{vi}.
|
||||
|
||||
@item horizontal-scroll-mode
|
||||
@vindex horizontal-scroll-mode
|
||||
This variable can be set to either @code{On} or @code{Off}. Setting it
|
||||
to @code{On} means that the text of the lines that you edit will scroll
|
||||
horizontally on a single screen line when they are longer than the width
|
||||
of the screen, instead of wrapping onto a new screen line. By default,
|
||||
this variable is set to @code{Off}.
|
||||
|
||||
@item mark-modified-lines
|
||||
@vindex mark-modified-lines
|
||||
This variable, when set to @code{On}, says to display an asterisk
|
||||
(@samp{*}) at the start of history lines which have been modified.
|
||||
This variable is @code{off} by default.
|
||||
|
||||
@item bell-style
|
||||
@vindex bell-style
|
||||
Controls what happens when Readline wants to ring the terminal bell.
|
||||
If set to @code{none}, Readline never rings the bell. If set to
|
||||
@code{visible}, Readline uses a visible bell if one is available.
|
||||
If set to @code{audible} (the default), Readline attempts to ring
|
||||
If set to @samp{none}, Readline never rings the bell. If set to
|
||||
@samp{visible}, Readline uses a visible bell if one is available.
|
||||
If set to @samp{audible} (the default), Readline attempts to ring
|
||||
the terminal's bell.
|
||||
|
||||
@item comment-begin
|
||||
@vindex comment-begin
|
||||
The string to insert at the beginning of the line when the
|
||||
@code{vi-comment} command is executed. The default value
|
||||
@code{insert-comment} command is executed. The default value
|
||||
is @code{"#"}.
|
||||
|
||||
@item meta-flag
|
||||
@vindex meta-flag
|
||||
If set to @code{on}, Readline will enable eight-bit input (it
|
||||
will not strip the eighth bit from the characters it reads),
|
||||
regardless of what the terminal claims it can support. The
|
||||
default value is @code{off}.
|
||||
|
||||
@item convert-meta
|
||||
@vindex convert-meta
|
||||
If set to @code{on}, Readline will convert characters with the
|
||||
eigth bit set to an ASCII key sequence by stripping the eigth
|
||||
bit and prepending an @key{ESC} character, converting them to a
|
||||
meta-prefixed key sequence. The default value is @code{on}.
|
||||
|
||||
@item output-meta
|
||||
@vindex output-meta
|
||||
If set to @code{on}, Readline will display characters with the
|
||||
eighth bit set directly rather than as a meta-prefixed escape
|
||||
sequence. The default is @code{off}.
|
||||
|
||||
@item completion-query-items
|
||||
@vindex completion-query-items
|
||||
The number of possible completions that determines when the user is
|
||||
|
|
@ -348,6 +350,45 @@ Readline will ask the user whether or not he wishes to view
|
|||
them; otherwise, they are simply listed. The default limit is
|
||||
@code{100}.
|
||||
|
||||
@item convert-meta
|
||||
@vindex convert-meta
|
||||
If set to @samp{on}, Readline will convert characters with the
|
||||
eigth bit set to an ASCII key sequence by stripping the eigth
|
||||
bit and prepending an @key{ESC} character, converting them to a
|
||||
meta-prefixed key sequence. The default value is @samp{on}.
|
||||
|
||||
@item disable-completion
|
||||
@vindex disable-completion
|
||||
If set to @samp{On}, readline will inhibit word completion.
|
||||
Completion characters will be inserted into the line as if they had
|
||||
been mapped to @code{self-insert}. The default is @samp{off}.
|
||||
|
||||
@item editing-mode
|
||||
@vindex editing-mode
|
||||
The @code{editing-mode} variable controls which editing mode you are
|
||||
using. By default, Readline starts up in Emacs editing mode, where
|
||||
the keystrokes are most similar to Emacs. This variable can be
|
||||
set to either @samp{emacs} or @samp{vi}.
|
||||
|
||||
@item enable-keypad
|
||||
@vindex enable-keypad
|
||||
When set to @samp{on}, readline will try to enable the application
|
||||
keypad when it is called. Some systems need this to enable the
|
||||
arrow keys. The default is @samp{off}.
|
||||
|
||||
@item expand-tilde
|
||||
@vindex expand-tilde
|
||||
If set to @samp{on}, tilde expansion is performed when Readline
|
||||
attempts word completion. The default is @samp{off}.
|
||||
|
||||
@item horizontal-scroll-mode
|
||||
@vindex horizontal-scroll-mode
|
||||
This variable can be set to either @samp{on} or @samp{off}. Setting it
|
||||
to @samp{on} means that the text of the lines that you edit will scroll
|
||||
horizontally on a single screen line when they are longer than the width
|
||||
of the screen, instead of wrapping onto a new screen line. By default,
|
||||
this variable is set to @samp{off}.
|
||||
|
||||
@item keymap
|
||||
@vindex keymap
|
||||
Sets Readline's idea of the current keymap for key binding commands.
|
||||
|
|
@ -357,7 +398,6 @@ Acceptable @code{keymap} names are
|
|||
@code{emacs-meta},
|
||||
@code{emacs-ctlx},
|
||||
@code{vi},
|
||||
@code{vi-move},
|
||||
@code{vi-command}, and
|
||||
@code{vi-insert}.
|
||||
@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
|
||||
|
|
@ -365,18 +405,44 @@ equivalent to @code{emacs-standard}. The default value is @code{emacs}.
|
|||
The value of the @code{editing-mode} variable also affects the
|
||||
default keymap.
|
||||
|
||||
@item mark-directories
|
||||
If set to @samp{on}, completed directory names have a slash
|
||||
appended. The default is @samp{on}.
|
||||
|
||||
@item mark-modified-lines
|
||||
@vindex mark-modified-lines
|
||||
This variable, when set to @samp{on}, says to display an asterisk
|
||||
(@samp{*}) at the start of history lines which have been modified.
|
||||
This variable is @samp{off} by default.
|
||||
|
||||
@item input-meta
|
||||
@vindex input-meta
|
||||
@vindex meta-flag
|
||||
If set to @samp{on}, Readline will enable eight-bit input (it
|
||||
will not strip the eighth bit from the characters it reads),
|
||||
regardless of what the terminal claims it can support. The
|
||||
default value is @samp{off}. The name @code{meta-flag} is a
|
||||
synonym for this variable.
|
||||
|
||||
@item output-meta
|
||||
@vindex output-meta
|
||||
If set to @samp{on}, Readline will display characters with the
|
||||
eighth bit set directly rather than as a meta-prefixed escape
|
||||
sequence. The default is @samp{off}.
|
||||
|
||||
@item show-all-if-ambiguous
|
||||
@vindex show-all-if-ambiguous
|
||||
This alters the default behavior of the completion functions. If
|
||||
set to @code{on},
|
||||
set to @samp{on},
|
||||
words which have more than one possible completion cause the
|
||||
matches to be listed immediately instead of ringing the bell.
|
||||
The default value is @code{off}.
|
||||
The default value is @samp{off}.
|
||||
|
||||
@item expand-tilde
|
||||
@vindex expand-tilde
|
||||
If set to @code{on}, tilde expansion is performed when Readline
|
||||
attempts word completion. The default is @code{off}.
|
||||
@item visible-stats
|
||||
@vindex visible-stats
|
||||
If set to @samp{on}, a character denoting a file's type
|
||||
is appended to the filename when listing possible
|
||||
completions. The default is @samp{off}.
|
||||
|
||||
@end table
|
||||
|
||||
|
|
@ -399,13 +465,13 @@ comfortable for you.
|
|||
@example
|
||||
Control-u: universal-argument
|
||||
Meta-Rubout: backward-kill-word
|
||||
Control-o: ">&output"
|
||||
Control-o: "> output"
|
||||
@end example
|
||||
|
||||
In the above example, @samp{C-u} is bound to the function
|
||||
@code{universal-argument}, and @samp{C-o} is bound to run the macro
|
||||
expressed on the right hand side (that is, to insert the text
|
||||
@samp{>&output} into the line).
|
||||
@samp{> output} into the line).
|
||||
|
||||
@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
|
||||
@var{keyseq} differs from @var{keyname} above in that strings
|
||||
|
|
@ -445,10 +511,10 @@ backslash
|
|||
When entering the text of a macro, single or double quotes should
|
||||
be used to indicate a macro definition. Unquoted text
|
||||
is assumed to be a function name. Backslash
|
||||
will quote any character in the macro text, including @key{"}
|
||||
and @key{'}.
|
||||
For example, the following binding will make @kbd{C-x \}
|
||||
insert a single @key{\} into the line:
|
||||
will quote any character in the macro text, including @samp{"}
|
||||
and @samp{'}.
|
||||
For example, the following binding will make @samp{C-x \}
|
||||
insert a single @samp{\} into the line:
|
||||
@example
|
||||
"\C-x\\": "\\"
|
||||
@end example
|
||||
|
|
@ -464,7 +530,7 @@ compilation features of the C preprocessor which allows key
|
|||
bindings and variable settings to be performed as the result
|
||||
of tests. There are three parser directives used.
|
||||
|
||||
@ftable @code
|
||||
@table @code
|
||||
@item $if
|
||||
The @code{$if} construct allows bindings to be made based on the
|
||||
editing mode, the terminal being used, or the application using
|
||||
|
|
@ -486,7 +552,7 @@ key bindings, perhaps to bind the key sequences output by the
|
|||
terminal's function keys. The word on the right side of the
|
||||
@samp{=} is tested against the full name of the terminal and the
|
||||
portion of the terminal name before the first @samp{-}. This
|
||||
allows @var{sun} to match both @var{sun} and @var{sun-cmd},
|
||||
allows @code{sun} to match both @code{sun} and @code{sun-cmd},
|
||||
for instance.
|
||||
|
||||
@item application
|
||||
|
|
@ -497,7 +563,7 @@ This could be used to bind key sequences to functions useful for
|
|||
a specific program. For instance, the following command adds a
|
||||
key sequence that quotes the current or previous word in Bash:
|
||||
@example
|
||||
$if bash
|
||||
$if Bash
|
||||
# Quote the current or previous word
|
||||
"\C-xq": "\eb\"\ef\""
|
||||
$endif
|
||||
|
|
@ -511,7 +577,109 @@ This command, as you saw in the previous example, terminates an
|
|||
@item $else
|
||||
Commands in this branch of the @code{$if} directive are executed if
|
||||
the test fails.
|
||||
@end ftable
|
||||
@end table
|
||||
|
||||
@node Sample Init File
|
||||
@subsection Sample Init File
|
||||
|
||||
Here is an example of an inputrc file. This illustrates key
|
||||
binding, variable assignment, and conditional syntax.
|
||||
|
||||
@example
|
||||
@page
|
||||
# This file controls the behaviour of line input editing for
|
||||
# programs that use the Gnu Readline library. Existing programs
|
||||
# include FTP, Bash, and Gdb.
|
||||
#
|
||||
# You can re-read the inputrc file with C-x C-r.
|
||||
# Lines beginning with '#' are comments.
|
||||
#
|
||||
# Set various bindings for emacs mode.
|
||||
|
||||
set editing-mode emacs
|
||||
|
||||
$if mode=emacs
|
||||
|
||||
Meta-Control-h: backward-kill-word Text after the function name is ignored
|
||||
|
||||
#
|
||||
# Arrow keys in keypad mode
|
||||
#
|
||||
#"\M-OD" backward-char
|
||||
#"\M-OC" forward-char
|
||||
#"\M-OA" previous-history
|
||||
#"\M-OB" next-history
|
||||
#
|
||||
# Arrow keys in ANSI mode
|
||||
#
|
||||
"\M-[D" backward-char
|
||||
"\M-[C" forward-char
|
||||
"\M-[A" previous-history
|
||||
"\M-[B" next-history
|
||||
#
|
||||
# Arrow keys in 8 bit keypad mode
|
||||
#
|
||||
#"\M-\C-OD" backward-char
|
||||
#"\M-\C-OC" forward-char
|
||||
#"\M-\C-OA" previous-history
|
||||
#"\M-\C-OB" next-history
|
||||
#
|
||||
# Arrow keys in 8 bit ANSI mode
|
||||
#
|
||||
#"\M-\C-[D" backward-char
|
||||
#"\M-\C-[C" forward-char
|
||||
#"\M-\C-[A" previous-history
|
||||
#"\M-\C-[B" next-history
|
||||
|
||||
C-q: quoted-insert
|
||||
|
||||
$endif
|
||||
|
||||
# An old-style binding. This happens to be the default.
|
||||
TAB: complete
|
||||
|
||||
# Macros that are convenient for shell interaction
|
||||
$if Bash
|
||||
# edit the path
|
||||
"\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f"
|
||||
# prepare to type a quoted word -- insert open and close double quotes
|
||||
# and move to just after the open quote
|
||||
"\C-x\"": "\"\"\C-b"
|
||||
# insert a backslash (testing backslash escapes in sequences and macros)
|
||||
"\C-x\\": "\\"
|
||||
# Quote the current or previous word
|
||||
"\C-xq": "\eb\"\ef\""
|
||||
# Add a binding to refresh the line, which is unbound
|
||||
"\C-xr": redraw-current-line
|
||||
# Edit variable on current line.
|
||||
"\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
|
||||
$endif
|
||||
|
||||
# use a visible bell if one is available
|
||||
set bell-style visible
|
||||
|
||||
# don't strip characters to 7 bits when reading
|
||||
set input-meta on
|
||||
|
||||
# allow iso-latin1 characters to be inserted rather than converted to
|
||||
# prefix-meta sequences
|
||||
set convert-meta off
|
||||
|
||||
# display characters with the eighth bit set directly rather than
|
||||
# as meta-prefixed characters
|
||||
set output-meta on
|
||||
|
||||
# if there are more than 150 possible completions for a word, ask the
|
||||
# user if he wants to see all of them
|
||||
set completion-query-items 150
|
||||
|
||||
# For FTP
|
||||
$if Ftp
|
||||
"\C-xg": "get \M-?"
|
||||
"\C-xt": "put \M-?"
|
||||
"\M-.": yank-last-arg
|
||||
$endif
|
||||
@end example
|
||||
|
||||
@node Bindable Readline Commands
|
||||
@section Bindable Readline Commands
|
||||
|
|
@ -527,6 +695,9 @@ the test fails.
|
|||
* Miscellaneous Commands:: Other miscellaneous commands.
|
||||
@end menu
|
||||
|
||||
This section describes Readline commands that may be bound to key
|
||||
sequences.
|
||||
|
||||
@node Commands For Moving
|
||||
@subsection Commands For Moving
|
||||
@ftable @code
|
||||
|
|
@ -608,12 +779,13 @@ for a string supplied by the user.
|
|||
|
||||
@item history-search-forward ()
|
||||
Search forward through the history for the string of characters
|
||||
between the start of the current line and the current point. This
|
||||
is a non-incremental search. By default, this command is unbound.
|
||||
between the start of the current line and the current cursor
|
||||
position (the `point'). This is a non-incremental search. By
|
||||
default, this command is unbound.
|
||||
|
||||
@item history-search-backward ()
|
||||
Search backward through the history for the string of characters
|
||||
between the start of the current line and the current point. This
|
||||
between the start of the current line and the point. This
|
||||
is a non-incremental search. By default, this command is unbound.
|
||||
|
||||
@item yank-nth-arg (M-C-y)
|
||||
|
|
@ -624,8 +796,8 @@ in the previous command begin with word 0). A negative argument
|
|||
inserts the @var{n}th word from the end of the previous command.
|
||||
|
||||
@item yank-last-arg (M-., M-_)
|
||||
Insert last argument to the previous command (the last word on the
|
||||
previous line). With an
|
||||
Insert last argument to the previous command (the last word of the
|
||||
previous history entry). With an
|
||||
argument, behave exactly like @code{yank-nth-arg}.
|
||||
|
||||
@end ftable
|
||||
|
|
@ -637,7 +809,7 @@ argument, behave exactly like @code{yank-nth-arg}.
|
|||
@item delete-char (C-d)
|
||||
Delete the character under the cursor. If the cursor is at the
|
||||
beginning of the line, there are no characters in the line, and
|
||||
the last character typed was not C-d, then return EOF.
|
||||
the last character typed was not @kbd{C-d}, then return @code{EOF}.
|
||||
|
||||
@item backward-delete-char (Rubout)
|
||||
Delete the character behind the cursor. A numeric arg says to kill
|
||||
|
|
@ -714,6 +886,23 @@ boundary. The killed text is saved on the kill-ring.
|
|||
@item delete-horizontal-space ()
|
||||
Delete all spaces and tabs around point. By default, this is unbound.
|
||||
|
||||
@item kill-region ()
|
||||
Kill the text between the point and the @emph{mark} (saved
|
||||
cursor position. This text is referred to as the @var{region}.
|
||||
By default, this command is unbound.
|
||||
|
||||
@item copy-region-as-kill ()
|
||||
Copy the text in the region to the kill buffer, so you can yank it
|
||||
right away. By default, this command is unbound.
|
||||
|
||||
@item copy-backward-word ()
|
||||
Copy the word before point to the kill buffer.
|
||||
By default, this command is unbound.
|
||||
|
||||
@item copy-forward-word ()
|
||||
Copy the word following point to the kill buffer.
|
||||
By default, this command is unbound.
|
||||
|
||||
@item yank (C-y)
|
||||
Yank the top of the kill ring into the buffer at the current
|
||||
cursor position.
|
||||
|
|
@ -729,7 +918,7 @@ the prior command is yank or yank-pop.
|
|||
|
||||
@item digit-argument (M-0, M-1, ... M--)
|
||||
Add this digit to the argument already accumulating, or start a new
|
||||
argument. M-- starts a negative argument.
|
||||
argument. @key{M--} starts a negative argument.
|
||||
|
||||
@item universal-argument ()
|
||||
Each time this is executed, the argument count is multiplied by four.
|
||||
|
|
@ -750,18 +939,74 @@ you can do command completion, if you are typing in a symbol to GDB, you
|
|||
can do symbol name completion, if you are typing in a variable to Bash,
|
||||
you can do variable name completion, and so on.
|
||||
@ifset BashFeatures
|
||||
See the Bash manual page for a complete list of available completion
|
||||
functions.
|
||||
Bash attempts completion treating the text as a variable (if the
|
||||
text begins with @samp{$}), username (if the text begins with
|
||||
@samp{~}), hostname (if the text begins with @samp{@@}), or
|
||||
command (including aliases and functions) in turn. If none
|
||||
of these produces a match, filename completion is attempted.
|
||||
@end ifset
|
||||
|
||||
@item possible-completions (M-?)
|
||||
List the possible completions of the text before the cursor.
|
||||
|
||||
@item insert-completions ()
|
||||
@item insert-completions (M-*)
|
||||
Insert all completions of the text before point that would have
|
||||
been generated by @code{possible-completions}. By default, this
|
||||
is not bound to a key.
|
||||
been generated by @code{possible-completions}.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item complete-filename (M-/)
|
||||
Attempt filename completion on the text before point.
|
||||
|
||||
@item possible-filename-completions (C-x /)
|
||||
List the possible completions of the text before point,
|
||||
treating it as a filename.
|
||||
|
||||
@item complete-username (M-~)
|
||||
Attempt completion on the text before point, treating
|
||||
it as a username.
|
||||
|
||||
@item possible-username-completions (C-x ~)
|
||||
List the possible completions of the text before point,
|
||||
treating it as a username.
|
||||
|
||||
@item complete-variable (M-$)
|
||||
Attempt completion on the text before point, treating
|
||||
it as a shell variable.
|
||||
|
||||
@item possible-variable-completions (C-x $)
|
||||
List the possible completions of the text before point,
|
||||
treating it as a shell variable.
|
||||
|
||||
@item complete-hostname (M-@@)
|
||||
Attempt completion on the text before point, treating
|
||||
it as a hostname.
|
||||
|
||||
@item possible-hostname-completions (C-x @@)
|
||||
List the possible completions of the text before point,
|
||||
treating it as a hostname.
|
||||
|
||||
@item complete-command (M-!)
|
||||
Attempt completion on the text before point, treating
|
||||
it as a command name. Command completion attempts to
|
||||
match the text against aliases, reserved words, shell
|
||||
functions, builtins, and finally executable filenames,
|
||||
in that order.
|
||||
|
||||
@item possible-command-completions (C-x !)
|
||||
List the possible completions of the text before point,
|
||||
treating it as a command name.
|
||||
|
||||
@item dynamic-complete-history (M-TAB)
|
||||
Attempt completion on the text before point, comparing
|
||||
the text against lines from the history list for possible
|
||||
completion matches.
|
||||
|
||||
@item complete-into-braces (M-@{)
|
||||
Perform filename completion and return the list of possible completions
|
||||
enclosed within braces so the list is available to the shell
|
||||
(@pxref{Brace Expansion}).
|
||||
|
||||
@end ifset
|
||||
@end ftable
|
||||
|
||||
@node Keyboard Macros
|
||||
|
|
@ -786,7 +1031,7 @@ in the macro appear as if typed at the keyboard.
|
|||
@ftable @code
|
||||
|
||||
@item re-read-init-file (C-x C-r)
|
||||
Read in the contents of your init file, and incorporate
|
||||
Read in the contents of the inputrc file, and incorporate
|
||||
any bindings or variable assignments found there.
|
||||
|
||||
@item abort (C-g)
|
||||
|
|
@ -794,9 +1039,9 @@ Abort the current editing command and
|
|||
ring the terminal's bell (subject to the setting of
|
||||
@code{bell-style}).
|
||||
|
||||
@item do-uppercase-version (M-a, M-b, ...)
|
||||
Run the command that is bound to the corresoponding uppercase
|
||||
character.
|
||||
@item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{})
|
||||
If the metafied character @var{x} is lowercase, run the command
|
||||
that is bound to the corresponding uppercase character.
|
||||
|
||||
@item prefix-meta (ESC)
|
||||
Make the next character that you type be metafied. This is for people
|
||||
|
|
@ -813,13 +1058,59 @@ command enough times to get back to the beginning.
|
|||
@item tilde-expand (M-~)
|
||||
Perform tilde expansion on the current word.
|
||||
|
||||
@item set-mark (C-@@)
|
||||
Set the mark to the current point. If a
|
||||
numeric argument is supplied, the mark is set to that position.
|
||||
|
||||
@item exchange-point-and-mark (C-x C-x)
|
||||
Swap the point with the mark. The current cursor position is set to
|
||||
the saved position, and the old cursor position is saved as the mark.
|
||||
|
||||
@item character-search (C-])
|
||||
A character is read and point is moved to the next occurrence of that
|
||||
character. A negative count searches for previous occurrences.
|
||||
|
||||
@item character-search-backward (M-C-])
|
||||
A character is read and point is moved to the previous occurrence
|
||||
of that character. A negative count searches for subsequent
|
||||
occurrences.
|
||||
|
||||
@item insert-comment (M-#)
|
||||
The value of the @code{comment-begin}
|
||||
variable is inserted at the beginning of the current line,
|
||||
and the line is accepted as if a newline had been typed.
|
||||
@ifset BashFeatures
|
||||
This makes the current line a shell comment.
|
||||
@end ifset
|
||||
|
||||
@item dump-functions ()
|
||||
Print all of the functions and their key bindings to the
|
||||
readline output stream. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file.
|
||||
of an @var{inputrc} file. This command is unbound by default.
|
||||
|
||||
@item dump-variables ()
|
||||
Print all of the settable variables and their values to the
|
||||
readline output stream. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file. This command is unbound by default.
|
||||
|
||||
@item dump-macros ()
|
||||
Print all of the readline key sequences bound to macros and the
|
||||
strings they ouput. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an @var{inputrc} file. This command is unbound by default.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item glob-expand-word (C-x *)
|
||||
The word before point is treated as a pattern for pathname expansion,
|
||||
and the list of matching file names is inserted, replacing the word.
|
||||
|
||||
@item glob-list-expansions (C-x g)
|
||||
The list of expansions that would have been generated by
|
||||
@code{glob-expand-word}
|
||||
is inserted into the line, replacing the word before point.
|
||||
|
||||
@item display-shell-version (C-x C-v)
|
||||
Display version information about the current instance of Bash.
|
||||
|
||||
|
|
@ -841,7 +1132,7 @@ argument is ignored.
|
|||
|
||||
@item emacs-editing-mode (C-e)
|
||||
When in @code{vi} editing mode, this causes a switch back to
|
||||
emacs editing mode, as if the command @code{set -o emacs} had
|
||||
@code{emacs} editing mode, as if the command @samp{set -o emacs} had
|
||||
been executed.
|
||||
|
||||
@end ifset
|
||||
|
|
@ -854,15 +1145,15 @@ been executed.
|
|||
While the Readline library does not have a full set of @code{vi}
|
||||
editing functions, it does contain enough to allow simple editing
|
||||
of the line. The Readline @code{vi} mode behaves as specified in
|
||||
the Posix 1003.2 standard.
|
||||
the @sc{POSIX} 1003.2 standard.
|
||||
|
||||
@ifset BashFeatures
|
||||
In order to switch interactively between @code{Emacs} and @code{Vi}
|
||||
editing modes, use the @code{set -o emacs} and @code{set -o vi}
|
||||
In order to switch interactively between @code{emacs} and @code{vi}
|
||||
editing modes, use the @samp{set -o emacs} and @samp{set -o vi}
|
||||
commands (@pxref{The Set Builtin}).
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
In order to switch interactively between @code{Emacs} and @code{Vi}
|
||||
In order to switch interactively between @code{emacs} and @code{vi}
|
||||
editing modes, use the command M-C-j (toggle-editing-mode).
|
||||
@end ifclear
|
||||
The Readline default is @code{emacs} mode.
|
||||
|
|
@ -871,5 +1162,5 @@ When you enter a line in @code{vi} mode, you are already placed in
|
|||
`insertion' mode, as if you had typed an @samp{i}. Pressing @key{ESC}
|
||||
switches you into `command' mode, where you can edit the text of the
|
||||
line with the standard @code{vi} movement keys, move to previous
|
||||
history lines with @samp{k}, and following lines with @samp{j}, and
|
||||
history lines with @samp{k} and subsequent lines with @samp{j}, and
|
||||
so forth.
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue