bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using perl's gnu-readline interface, howto 'completion' & 'filter hi


From: Chet Ramey
Subject: Re: using perl's gnu-readline interface, howto 'completion' & 'filter history'?
Date: Sat, 10 Jan 2015 22:54:02 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 1/9/15 3:33 PM, Linda Walsh wrote:
> I have a little calculator interface that I use readline for.
> Imagine my surprise when I type 1+<TAB> and get a list of files
> to add to 1.  Um... not ideal?

OK.  If you don't want completion, bind TAB to self-insert.

> 
> I add a time/date stamp to each line typed in.
> (HISTTIMEFORMAT="%m%d@%H%M%S:")
> 
> In bash when I scroll back, I don't the time
> entries, but I do in my calculator.  How can I filter
> them out?

Use read_history() or read_history_range() to read the history file.  If
the perl code is reading lines from the history file itself, stop doing
that.

> Note, I do set some options, but seem to need to write the timestamp
> into the history file myself.
>        $ra->{history_comment_char}='#';
>        $ra->{history_expansion_char}="";
>        $ra->{history_write_timestamps}=1;
>        $ra->{history_quotes_inhibit_expansion}=1;
> 
> histfile update writes the time itself to get the time in the .hist file...
> 
>        if ($histfile_h) {
>            printf($histfile_h "#%d\n%s\n", CORE::time,$_) unless $_ eq 'quit';
>            $histfile_h->flush;
>        }
> 
> i.e. the write_timestamps option seems to be having no effect -- unless
> it's writing another history file someplace else...?

If the perl code is using write_history() or append_history() and has
correctly reflected the history_write_timestamps variable, you don't need
to do anything else.  If the `flush' method isn't using those functions,
then it needs to be updated.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]