current cursor position

walter harms wharms at bfs.de
Thu Jul 22 10:17:50 UTC 2010



Christopher Barry schrieb:
> On Sun, 2010-07-18 at 21:55 +0200, Denys Vlasenko wrote:
>> On Saturday 17 July 2010 19:12, Christopher Barry wrote:
>>> All,
>>>
>>> looking for an easy way to capture the current cursor position. found a
>>> reference to 'ESC [ 6 n', but not sure how that works. I tried
>>> # echo -e '\e[6n'
>>> but that does not do what I expect.
>> It makes terminal talk:
>>
>> shadow:~# echo -ne '\e[6n'; hexdump -vC
>> ^[[6;1R (here I press ^D^D to let hexdump see EOF) 00000000  1b 5b 36 3b 31 52                                 |.[6;1R|
>> 00000006
>>
> 
> Denys, I have no idea what the heck that means! :)
> 
> I was actually looking for something to put in a script, kinda like:
> 
> cp=$(get_cursor_position)
> [[ ${cp} -gt 0 ]] && echo
> 
> so my logger would not be writing at the end of an unrelated line.
> 
> 

i am not sure what problem you try to solve. you can take a look at tput
or send the request (depending on your $TERM) via printf/echo

re,
 wh



More information about the busybox mailing list