Readline Support (Units: A Unit Conversion Program and Scientific Calculator)

## 20 Readline Support ¶

If the `readline` package has been compiled in, then when `units` is used interactively, numerous command line editing features are available. To check if your version of `units` includes `readline`, invoke the program with the `--version` option.

For complete information about `readline`, consult the documentation for the `readline` package. Without any configuration, `units` will allow editing in the style of emacs. Of particular use with `units` are the completion commands.

If you type a few characters and then hit `ESC` followed by `?`, then `units` will display a list of all the units that start with the characters typed. For example, if you type `metr` and then request completion, you will see something like this:

    You have: metr
    metre             metriccup         metrichorsepower  metrictenth
    metretes          metricfifth       metricounce       metricton
    metriccarat       metricgrain       metricquart       metricyarncount
    You have: metr

If there is a unique way to complete a unit name, you can hit the `TAB` key and `units` will provide the rest of the unit name. If `units` beeps, it means that there is no unique completion. Pressing the `TAB` key a second time will print the list of all completions.

The readline library also keeps a history of the values you enter. You can move through this history using the up and down arrows. The history is saved to the file `.units_history` in your home directory so that it will persist across multiple `units` invocations. If you wish to keep work for a certain project separate you can change the history filename using the `--history` option. You could, for example, make an alias for `units` to `units --history .units_history` so that `units` would save separate history in the current directory. The length of each history file is limited to 5000 lines. Note also that if you run several concurrent copies of `units` each one will save its new history to the history file upon exit.