history: Managing the History File
1
1 2.3.6 Managing the History File
1 -------------------------------
1
1 The History library can read the history from and write it to a file.
1 This section documents the functions for managing a history file.
1
1 -- Function: int read_history (const char *filename)
1 Add the contents of FILENAME to the history list, a line at a time.
1 If FILENAME is 'NULL', then read from '~/.history'. Returns 0 if
1 successful, or 'errno' if not.
1
1 -- Function: int read_history_range (const char *filename, int from,
1 int to)
1 Read a range of lines from FILENAME, adding them to the history
1 list. Start reading at line FROM and end at TO. If FROM is zero,
1 start at the beginning. If TO is less than FROM, then read until
1 the end of the file. If FILENAME is 'NULL', then read from
1 '~/.history'. Returns 0 if successful, or 'errno' if not.
1
1 -- Function: int write_history (const char *filename)
1 Write the current history to FILENAME, overwriting FILENAME if
1 necessary. If FILENAME is 'NULL', then write the history list to
1 '~/.history'. Returns 0 on success, or 'errno' on a read or write
1 error.
1
1 -- Function: int append_history (int nelements, const char *filename)
1 Append the last NELEMENTS of the history list to FILENAME. If
1 FILENAME is 'NULL', then append to '~/.history'. Returns 0 on
1 success, or 'errno' on a read or write error.
1
1 -- Function: int history_truncate_file (const char *filename, int
1 nlines)
1 Truncate the history file FILENAME, leaving only the last NLINES
1 lines. If FILENAME is 'NULL', then '~/.history' is truncated.
1 Returns 0 on success, or 'errno' on failure.
1