spec

Software for Diffraction

history

command recall facility

SYNOPSIS

history [n|-n]

get_history(n)

DESCRIPTION

The history command lists the most recently entered commands. The get_history(n) returns entries from the saved history (added in spec release 6.07.07).

The maximum number of commands that can be saved to history can be set using spec_par("history_size", size). The default history size is 1000. Prior to spec release 6.05.01, the maximum number of saved commands was fixed at 1000.

With the option n, history displays the n most recent commands. A -n lists the n most recent commands in reverse order.

For the get_history(n) function, if n is positive, returns the specified history item as a string. If n is negative, subtracts the absolute value from the current history number and returns that history item. For example, get_history(-1) returns the previous command. If the specified number is out of range, returns an empty string. No error message is displayed.

Command history is saved when spec exits and restored when spec restarts with the same state file. When starting spec fresh with the -f or -F flags, the -h flag retains the previous command history (as of spec release 6.05.01).

BASIC BUILT-IN HISTORY

The rest of this document describes the basic built-in history syntax. However, spec is almost always linked with a command-line editing library (by default libedit, though readline is also supported) which provides a much richer history and command-line editing experience. See the libedit help file for details.

The history feature lets you recall previous commands. The syntax is a subset of that of the csh history command. Examples of the recognized syntax are:

!! - redo the previous command.
!14 - redo command number 14.
!-2 - redo the second to previous command.
!asc - redo the last command that began with asc.
!asc -10000 - As above and append -10000 to the command.

The command number is prepended to the spec prompt as an aid in using the history feature. Only commands typed at the keyboard are remembered for history. The history feature cannot be used in command files.

Command recall must occur at the beginning of a line. Text may follow the command-recall word to extend that command.

Appending :s/left/right/ to a recalled command will modify the first occurrence of the string left in the recalled command to the characters right. The delimiter of the left and right strings may be any character. The final delimiter is optional. If left is empty, the last entered left string is used as the pattern to match.

In addition, ^left^right^ at the start of a line is shorthand for !-1:s/left/right/. In this case, the circumflex (^) must be used as the delimiter. The final delimiter is optional.

SEE ALSO