Cursor resets in linux console


I'm using a plain linux console, usually with screen, and I have set a cursor
that's easier to read using a control code:

printf '\e[?3c'

This is a standard linux console code.

However as soon as I start moc my cursor resets to the standard thin underscore
that's pretty unreadable.

Any way around this? I looked at the cursor and TERM options, but nothing


Congratulations, I haven't come across this one before (and it's nice to have a post which isn't spam for a change).

I tried this on lynx and vi (elvis) and both preserve the setting on exit, so MOC is either doing something it shouldn't or not doing something it should with regards to the cursor setting. Fortunately, I have two example applications to compare against.

To answer your immediate question: no I don't think there is a way around it within MOC, it's simply a deficiency which will have to be addressed. But you could wrap the MOC invocation in a script which resets the cursor to your preference after MOC exits.

After some investigation, it is apparant that this resetting of the cursor style occurs because MOC turns the cursor off (makes it invisible) while it's running to make the screen more pleasing. You can use the UseCursorSelection configuration option to prevent this but it's really intended for use by people with ancillary screen-reading devices. But even then, if you need to enter a text string (such as a directory path to go to) the cursor will revert to its default style.

(The reason why lynx and elvis appear to preserve the cursor is that they don't actually turn it off.)

There is no way I could find within ncurses (the library MOC uses for screen formatting) to preserve then restore the current cursor style, and it appears that it is from deep within ncurses that the cursor style is being reset when the application changes its visibility.

However, by manpulating the reset sequences in your termcap or terminfo settings you can probably both achieve what you want and not have to be repeatedly using printf. Have a look at this article which (along with the articles it references) will explain how to do that.

Please let us know whether or not that works for you.

The problem with setting it via a script on exit is that I usually leave moc running, and it affects other screen windows as soon as it starts. I also had this problem with mutt, but with mutt I could run it with TERM=xterm-color and that would stop it resetting the cursor and colours. I do see the cursor blinking in mutt now, but that's not so annoying as having the cursor reset every time. Unfortunately I haven't got this to work in moc yet, or at least maybe I haven't found the right $TERM yet to confuse it enough :)

I'll have a look at the UseCursorSelection option. I don't think I saw that one before.

I'm not sure how lynx does it, but elinks has an option to 'block the cursor', which basically just hides it at the bottom right corner of the screen where it's not noticable. That might be a nice option for moc to have, if it's possible.

I'll have a look at termcaps to see if I can find a way. If I find anything I'll let you know.

Thanks for the ideas.

I also had this problem with mutt, but with mutt I could run it with TERM=xterm-color and that would stop it resetting the cursor and colours.

So what if you created a new terminal entry which is a copy of the current one but uses the appropriate reset sequence and set that as MOC's $TERM? If that works, I think it's going to be the most elegant solution.

It's a while since I raised this as an issue, so I thought I'd add what really fixed it for me, not just in moc, but all applications that reset the cursor.

The solution is to use an option on the kernel command line at boot:


The 3 being the 1/3 block. Now anything that does the equivalent of `tput cnorm' will reset it back to that cursor shape.


Thank you for reporting back your solution. It means I no longer have to keep reviewing the bug report and also that others can benefit from your discovery.

So I can now close it and sleep at nights.