2

I am running Ubuntu 14.04 and using one of the virtual terminals (TTY[1-6], accessible via Ctrl-Alt-F[1-6]); I want to permanently change the appearance of my cursor from the apparent default, a blinking underline, to a blinking box. I can change it temporarily, but it is consistently resetting when certain applications are run.

Initially the cursor style in the TTY sessions was a blinking underline. I found that I could change it to a blinking box with the command:

printf '\e[?8c'

This changes the cursor in the terminal and is reflected in programs like emacs or elinks. So I placed the above command into my .bashrc.

However, certain applications seem to revert the cursor style to a blinking underline, and this persists even after exiting those applications. I can reset the cursor style to a blinking box by re-issuing the above command, sourcing .bashrc, or by logging out and back in.

For example, consider how the following 3 applications (tmux, emacs, elinks) affect the cursor style:

  • tmux: the cursor style is immediately set to a blinking underline, this style is maintained in all applications run within tmux, and the change persists after exiting tmux. The above printf command has no effect in tmux.
  • emacs: the cursor style is whichever style was active when I ran it, and then the style changes to a blinking underline upon exiting emacs.
  • elinks: the cursor style is whichever style was active when I ran it, and the cursor style does NOT change upon exiting elinks.

I should note that I have emacs settings to set the cursor style (within emacs) to a box, and that while I have searched for a setting to set cursor style within tmux I could not find anything beyond an entry in tmux's man page, which states:

tmux understands some extensions to terminfo(5):

 [...]

 Cs, Csr
         Change the cursor style.  If set, a sequence such as this may be used to change the cursor to an underline:

               $ printf '\033[4 q'

         If Csr is set, it will be used to reset the cursor style instead of Cs.

Unfortunately I do not understand how to "set Cs" and, as mentioned above, I have tried issuing the printf command to set the cursor style inside tmux to no avail.

Another interesting note is that the issue with cursor style changing does not occur when running an X terminal emulator, such as XFCE4 Terminal. This only seems to occur in the TTYs.

I can't seem to find any information about other people that have had this problem or settings within the mentioned applications that might be causing the problem. What is causing this problem and how can I resolve it so that I consistently have a blinking block cursor style?

1

The terminal features are not available with all terminals, and may differ with versions of tmux. I see the description cited in tmux 1.6 on Debian 7. Ubuntu 14.04 is a little old, and has tmux 1.8 (same description).

The example given in the manual page looks like DECSCUSR, which is supported by xterm starting with patch #252 in 2009. Refer to XTerm Control Sequences:

CSI Ps SP q
          Set cursor style (DECSCUSR, VT520).
            Ps = 0  -> blinking block.
            Ps = 1  -> blinking block (default).
            Ps = 2  -> steady block.
            Ps = 3  -> blinking underline.
            Ps = 4  -> steady underline.
            Ps = 5  -> blinking bar (xterm).
            Ps = 6  -> steady bar (xterm).

To use them, you would make a modified terminfo entry using ncurses's tic, e.g.,

infocmp -x >foo
vi foo
tic -x foo

adding this line (with a leading tab, like the other capabilities):

Cs=\E[%p\sq, Csr=\E[0\sq,

However, checking the source for tmux 2.1, it no longer reads those terminfo features, and has been modified to use Cs and Cr for setting color (done in older versions using Cc and Cr). The newer version has built-in logic for recognizing DECSCUSR without a terminfo extension.

VTE-based terminals (such as XFCE terminal) may (depending on version) implement DECSCUSR, but Linux console is unlikely to do this, since it implements only a subset of the VT220 while DECSCUSR is from a VT520 terminal (a superset of VT220).

You will see differences with other applications such as emacs because DECSCUSR overlaps other cursor-style features such as the blinking cursor feature, set or reset with the cvvis and cnorm capabilities from terminfo for xterm:

CSI ? Pm h
          DEC Private Mode Set (DECSET).
            Ps = 1 2  -> Start Blinking Cursor (att610).

However, you seem to want to modify the cursor appearance in the Linux console (also called a virtual console). DECSCUSR has no effect there.

To make your cursor a blinking block all time, you would have to change the cursor-appearance capabilities in the terminal description(s) which you are using. Those are civis (make the cursor invisible), cnorm (make the cursor a "normal" appearance) and cvvis (make the cursor very visible):

  • Making both of those \e[?8c in the "linux" entry would tell programs such as emacs using that entry to use your blinking-box cursor.
  • tmux also reads the terminal entry, looking at cnorm and civis.
  • elinks on the other hand is hard-coded, ignoring the terminal database. In a quick read of its source, I do not see any escape sequences which reset the terminal or modify the cursor appearance.

Since you are using tmux, you may also have to modify the xterm (so that applications running inside tmux use that cursor style). But test without this first: if you must, you can probably combine the \e[?8c with the existing cnorm string, since xterm ignores \e[?8c.

3
  • Thanks for your response. I tried modifying the terminfo entry using tic as you showed but it doesn't seem to have had any effect. Is there anything else that I can try? – llzrk Jan 30 '16 at 1:14
  • Thank you again. Your updated comment, in addition to the answers to this question lead me to the solution: tmux refers to the cnorm entry in infoterm to set the cursor style, so I issued the command "tput cnorm '\e[?8c'" to set the cnorm entry and "tput cvvis '\e[?8c'" to set the cvvis entry (for good measure). After logging back in and starting tmux, the fix appears to work! – llzrk Jan 30 '16 at 14:28
  • no problem: I started off thinking you were attempting to make DECSCUSR work, then realized the issue was emacs, etc. – Thomas Dickey Jan 30 '16 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.