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

Re: bindkey -s question



Danek Duvall wrote:
> 
> I'm trying to bind ^L to a key sequence that will reset my xterm saved
> lines.  The escape sequence ^[c does the trick if I do
> 
>     echo -n c
> 
> at the command line.  However, if I try
> 
>     bindkey -s "^L" "echo -n ^[c"
> 
> it just prints a new prompt as if I'd typed return.  (Note I've typed all
> the control charaters using ^V first; I'm just typing them safely here.)
                              ^^
Right here's your key - -s puts the keys on the line as if you typed
them.  Try typing 'echo -n ^[c' on the command line and see what
happens.  Anyway, I think 'echo -n ^V^O' is what you really want; you
then don't need to associate it with clear-screen.

> I managed to get somewhat the behavior I want by
> 
>     zle -N clear-screen2
>     function clear-screen2 () { echo -n ^[c; zle clear-screen }
>     bindkey "^L" clear-screen2
> 
> Without the call to clear-screen, the prompt doesn't get printed, but with
> it there's a slight flash.

Which tells you what would happen with what you're trying with the
bindkey you're asking about - you'd get no prompt.

I handle this with
alias sanity='echo ^O; stty sane; stty -erase ^H'

I avoid the situation enough that a keybinding is not called for.
Considering the number of actual terminal lockups available from the
same source as your messed up charset, I think avoidance is probably a
good idea.  (I saw one of those happen to a sysadmin at work, who was on
console on a machine which must not go down.  Oops.  Funny thing was, he
didn't realize it was a binary file until I showed it to him with less.
And some people wonder why I hate /bin/more with a passion.)

> I'm using xterm-70, if that makes any difference.

It does - it means you're talking about a dec-vt style terminal, which
is what I know best.  You'll only have problems applying this to
something weird like wyse terminals (what the hey?!?) or ansi
(standards?  Who ever follows standards?) (though dec-vt style is close
enough to ansi that it might carry over.)

Ed



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