Did you know ... | Search Documentation: |
Pack genutils -- prolog/rcutils.pl |
This module provides confirm_on_halt/0, to make it harder to exit Prolog unintentionally due to over-enthusiastic Ctrl-D pressing, persistent_history/2, to keep and periodically save the current command line history to an arbitrary file, and defines the file_search_path/2 location 'home', which maps to the expand_file_name/2 expansion of '~'.
:- if(exists_source(library(rcutils)))
:- use_module(library(rcutils))
.
:- persistent_history('.swipl.history',[interval(300)])
.
:- confirm_on_halt.
:- endif.
===
If called during SWI Prolog initialisation (ie in the ~/.swiplrc file, in a command line -g goal, or in a program loaded with -s on the command line) then the line editor and history mechanisms will not have been initialised yet, so you must load whichever line editor library you like (readline or editline) first.
Valid options are:
For example, the author finds it useful to add the following to his ~/.swiplrc:
:- use_module(library(hostname)). persistent_history :- hostname(Hostname), atom_concat('.swipl_history.',Hostname,HistFile), load_files(library(readline), [if(not_loaded)]), set_prolog_flag(readline, readline), % work around bug in readline foreign library persistent_history(HistFile,[interval(60)]).
This means that any program can call persistent_history/0 to get a host specific history file, which is useful when a directory is shared or synchronised across several machines.