Hi misc@ and Anton,

This is a continuation of https://marc.info/?t=152277773500003&r=1&w=2
from April:

On Wednesday, April 4, 2018 2:01 AM, Anton Lindqvist <an...@openbsd.org> wrote:
> On Tue, Apr 03, 2018 at 01:45:13PM -0400, Tinker wrote:
> > I looked around for advise for how to make ctrl+L get bash's behavior
> > of first clearing the screen and then redrawing the current command
> > prompt including content that has been typed.
> > "bind -m '^L'=clear'^J'" is a partial solution to this problem as it
> > will have that effect but only if the command line is empty.
> > If the command line is not empty then instead the text "clear" will be
> > typed into it, and an enter key press will be emulated.
> > Is there any way to give ksh the clear+redraw behavior also when typing
> > started, so same independent of whether typing started or not i.e. just
> > like in bash?
>
> Try this one: bind -m '^L'=^Uclear'^J^Y'

Thank you so much for coming up with this one.

It does work as advertised - it clears the screen while keeping the
content and cursor position in the command line.

I just realized that it does one inadvertent thing though: It adds a
line to ksh's history with the text "clear", which will surprise you
and unnecessarily steal some attention next time you press the up
arrow.

I found this thread https://marc.info/?t=153299615600004&r=1&w=2 which
discusses how to get the "clear" out of the ksh history file, and, the
trick described there also applies to the history - great!

So your suggestion above is amended with:

     bind -m '^L'=^U clear'^J^Y'
     HISTCONTROL=ignorespace

I find the notion of using space prefix as ignore condition just a bit
primitive and with a very big risk of unintentional trigging, e.g., if
you paste a script in your shell its indentation would make it ignored.

Could some other ^ shortcut be an ignore-this-line-from-history marker?

^I as in ignore, "bind -m '^L'=^U^Iclear'^J^Y'" :)

Anyhow it works - great, thanks again for pointing out.

Tinker

Reply via email to