Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ZLE_LINE_ABORTED: how to restore the last non-blank aborted line?

On Thu, Sep 29, 2016 at 9:32 AM, Hong Xu <hong@xxxxxxxxxx> wrote:
> On 09/29/2016 12:12 AM, Bart Schaefer wrote:
>> On Sep 27,  9:11pm, Hong Xu wrote:
>> }
>> } ZLE_LINE_ABORTED would turn empty if ^C is pressed on an empty line
>> } disregarding what it was. This is annoying since sometimes auto
>> } completion stuck and more than one ^C is used to cancel that.
>> }
>> } Is there any way to preserve it in this case in zsh?
>> Can you give a more specific example?  Normally any buffer preceding
>> the line on which the abort occurred is already in the history and can
>> be recalled with up-line-or-history et al.; ZLE_LINE_ABORTED is only
>> needed to capture lines that haven't yet been added to history.
> Sure. For example,
>     emacs path/to/some/file
> Now assume that the tab completion stucks at this point and the user
> accidentally presses two ^C to cancel that. Now, ZLE_LINE_ABORTED is
> empty but the user would prefer to restore the line "emacs
> path/to/some/file".

You can have your zle-line-init hook record the value of
$ZLE_LINE_ABORTED is non-empty.

Mikael Magnusson

Messages sorted by: Reverse Date, Date, Thread, Author