I know I can move the cursor with the escape codes, and I can also print at the cursor. What I'd like to know is if it is possible to pull the character under the cursor.

I tried searching for such a code, but failed. So I assume it is not possible, but I'd like to ask if there is some way I failed to find.

  • 1
    Your shell may be able to do something similar for characters on the current command line (while typing, but before execution); see, for example, the Readline library in man bash and Z-shell's line editor in man zshzle. I'm unaware of any thing that would interact with arbitrary positions in the terminal emulator window.
    – chepner
    May 23, 2013 at 0:16

2 Answers 2


This is not possible unless you modify your terminal emulator to make it possible; use curses library or equivalent.


The DECRQCRA escape sequence allows you to query the checksum of a rectangular area.

The checksum is basically the sum of the character codes there. And if you choose a 1×1 rectangular area then... bamm, there's the character code.

This feature is used e.g. by the test suite esctest.

By far not every terminal supports it. Some don't implement it because of laziness (practically no one needs this feature). Some deliberately don't implement it because of privacy / security concerns (if you ssh/telnet/netcat to a remote machine which has been compromised, then it can look at your screen and see earlier contents). Some make it subject to some sort of developer flag, in order to be able to run esctest, but not to open up that privacy / security hole by default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .