Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: prompt and prompt_cr option
- X-seq: zsh-workers 20472
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Danek Duvall <duvall@xxxxxxxxxxxxxx>
- Subject: Re: prompt and prompt_cr option
- Date: Mon, 11 Oct 2004 18:52:10 -0700 (PDT)
- Cc: zsh-workers@xxxxxxxxxx, Jordan Breeding <jordan.breeding@xxxxxxx>
- In-reply-to: <20041011232857.GB11629@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <546D60C2-1A06-11D9-B624-000A95A6C222@xxxxxxx> <Pine.LNX.4.61.0410111456360.9416@xxxxxxxxxxxxxxxxxx> <20041011232857.GB11629@xxxxxxxxxxxxxxxxxxxxx>
- Reply-to: zsh-workers@xxxxxxxxxx
On Mon, 11 Oct 2004, Danek Duvall wrote:
> On Mon, Oct 11, 2004 at 03:11:43PM -0700, Bart Schaefer wrote:
>
> > For certain types of terminals you might be able to query the current
> > cursor position and do something clever when it is not in column zero
>
> On the other hand, you could write a precmd function that did this and
> spit out an extra newline if necessary (and set nopromptcr), no?
Unfortunately it's not quite that simple.
As far as I can tell, there's no terminfo/termcap capability that defines
the "report cursor position" string. So it can't easily be determined
whether the terminal supports it, or what to send.
If the terminal is ANSI/ECMA compliant, the query string is $'\e[6n' and
the response is $'\e[ll;ccR' where cc and ll are the column and line
numbers -- but if it is not ANSI then sending that string won't give any
response (and may just garble the output further).
So the following might work, or might not. It uses the prompt printed by
the read builtin to query the terminal and the combination of IFS and the
-d option to parse the response.
precmd() {
local escape colno lineno
IFS='[;' read -s -d R escape\?$'\e[6n' lineno colno
(( colno > 1 )) && echo ''
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author