Some terminals may support position request, like CSI 6 n . If supported, the position will be displayed as CSI Pl;Pc R for instance
$ echo -e "\e[6n"; xxd ^[[4;1R 0000000: 1b5b 343b 3152 0a .[4;1R.
This indicates that the cursor is in the first column of the 4th row (counting from 1).
However, this probably should not be relied on, since in reality it is not so many terminals.
source share