On Fri, May 11, 2012 at 10:57:58AM -0400, Aaron Davies wrote:
> i'd like to redefine ctrl-l to do what it does in bash--clear the screen.
> 
> what i have so far is this, but it has (at least) two issues--it yanks back
> the last kill even if there's nothing in the current command line, and it
> pushes the "clear" into the history. is it possible to get rid of both of
> those behaviors?
> 
> > keybind $'\cl'   $'\cuclear\r\cy'

I'd suggest doing something with the KEYBD trap.  For example, you might find
the following to be a good starting point.

    function foo {
        if [[ ${.sh.edchar} == $'\014' ]]; then
            clear
            print -nr -- "${.sh.edtext}"
            .sh.edchar=$'\0'
        fi
    }
    trap foo KEYBD

However, don't overlook taking advantage of editing modes.  For example, if
you use the emacs editing option, you can take advantage of the default
processing of ^L, which redraws the current line (including the proper
prompt).  Much nicer!  In that case, you can use a shorter function, relying
on ksh's default handling of ^L in emacs mode to redraw the line after you
clear the screen.

    function foo { [[ ${.sh.edchar} == $'\014' ]] && clear; }

Look into the sh namespace and the KEYBD trap to do more exciting things along
these lines.

Cheers,
Bob

-- 
Bob Krzaczek, Chester F. Carlson Center for Imaging Science, RIT
phone +1-585-4757196, email [email protected], icbm 43.08586N 77.67744W

Attachment: pgpG06SzzYiQ3.pgp
Description: PGP signature

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to