Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: PATCH: zftp xterm titlebar
- X-seq: zsh-workers 9015
- From: "Andrej Borsenkow" <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: "Alexandre Duret-Lutz" <alexandre.duret@xxxxxxxxxxxxxx>, <zsh-workers@xxxxxxxxxxxxxx>
- Subject: RE: PATCH: zftp xterm titlebar
- Date: Mon, 13 Dec 1999 15:08:03 +0300
- Importance: Normal
- In-reply-to: <7d3dt75et0.fsf@xxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
> AB> BTW is it possible to get the current window title?
>
> I could print it with :
>
> $ echo '[21t'
>
> But does someone know how to catch this in a shell script ? Is there
> a better way than using script(1) ?
>
Quick'n'dirty
bor@itsrm2% ./rt.zsh
Title is: bor@itsrm2:~/test/zsh
bor@itsrm2% cat rt.zsh
#!/tools/bin/zsh
typeset name
stty -icanon -echo < /dev/fd/0
print -n "\033[21t"
read -u0 -k 1 c
((#c == 27)) || exit
read -u0 -k 1 c
((#c == 93)) || exit
read -u0 -k 1 c
((#c == ##l)) || exit
read -u0 -k 1 c
while ((#c != 27)) {
name[$#name+1]=$c
read -u0 -k 1 c
}
read -u0 -k 1 c
((#c == ##\\)) || name=()
print Title is: $name
(For some reasons, neiter ##] nor ##\] worked)
The problem is, output of dtterm appears as input to zsh. When you start new
script (as in this case) tty mode is reset to it's default, that is line
buffered and echoing input. The stty above is needed to turn off line buffer
(else you would need to press CR) and to turn off echo.
The stty seems to be needed even if you call the above from inside of your login
shell. I have "frozen" tty; in general case you may need to save/restore tty
settings.
Hmm ... as stty is highly system-dependent, may be stty module would be very
nice.
/andrej
Messages sorted by:
Reverse Date,
Date,
Thread,
Author