Reading terminal cursor position from the shell ?

Reading terminal cursor position from the shell ?

Post by Frank Hofman » Fri, 16 Jan 1998 04:00:00

subject line says it all:
I want to read the current cursor position (vt100 terminal) into
the shell. vt100 reports it when I do
        echo -e '\e[6n'
but its output seemingly goes to the tty only and not to the
shell's stdin.
Is there any way to read this back from within the shell ?
How ?

Thanks ahead for any answers.


Note: reply email address line modified. Do
        echo $addressline | sed -e 's/_\.*_/i/g'
to recover if you really don't want to reply to the newsgroup ...


1. : reading cursor position on vt100 terminal

Hi folks,

I've got a (seemingly) simple question.
How do I read back the current cursor position from a VT100-compatible
terminal using shell commands ?
Note: I'm using bash.
I can do the following
        echo -en '\e[6n'; read
and I get the correct string into $REPLY (\e[<col>;<row>R), but ONLY after
I pressed <Enter>.
But can this be done automatically ?
I've tried
        stty min 5 time 10
to make the read timeout after 1 second, but it doesn't work, I still have
to press the <Enter> key or it will wait indefinitely.

what's wrong here ?
Can this be done without writing a special C program for it ?

Thanks for any answers,

Frank Hofmann                      Telefon: [(0049)931 888] 5876
Sysadmin CIP-Pool Physik           Zimmer:  C 060
Find out more:

  I will not say: Do not weep, for not all tears are an evil.

2. Mailserverproblem...

3. Sorry, your terminal can't do absolute cursor positioning.

4. Linux and Windows versioned Email Client

5. HELP: find cursor position on terminals

6. ditto 3200 - mt erase doesn't work!

7. How do I read the cursor position?

8. RH5 + SCSI (AVA-1505) no go

9. Cursor positioning/reading

10. How to stop shell reading from terminal?

11. How to set the cursor-position

12. Saving/restoring the console cursor position?

13. q: get current cursor position