14

Is there any way to change the cursor to a "vertical line" instead of a box in XTERM?

box: ■

line: |

busybear
  • 10,194
  • 1
  • 25
  • 42
toughtalker
  • 461
  • 2
  • 6
  • 14

3 Answers3

33

It seems xterm has added support for the vertical bar or I-beam cursor.

You can change the cursor by inserting one of the following lines in your ~/.bashrc file (if you use bash):

echo -e -n "\x1b[\x30 q" # changes to blinking block
echo -e -n "\x1b[\x31 q" # changes to blinking block also
echo -e -n "\x1b[\x32 q" # changes to steady block
echo -e -n "\x1b[\x33 q" # changes to blinking underline
echo -e -n "\x1b[\x34 q" # changes to steady underline
echo -e -n "\x1b[\x35 q" # changes to blinking bar
echo -e -n "\x1b[\x36 q" # changes to steady bar

References:

  • https://code.google.com/p/iterm2/issues/detail?id=2248
  • xterm changelog entry for patch #282:

Patch #282 - 2012/09/28

  • extend DECSCUSR to provide a way to set the cursor to a vertical bar (patch by Paul Bolle).
  • 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.
    
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • And two more from me that are always demanded as well: `echo -ne "\x1b[?25l"` will __hide__ the cursor; `echo -ne "\x1b[?25h"` will __show__ the cursor again. For me this is essential when I want to "misuse" an `xterm` as a (pseudo-)write-only output console. __Besides__: Those lines seem to contain a little too much. A mere `echo -ne "\x1b[6 q"` will change to a steady bar. No idea what the "\x3" is meant for. Just omit it. – syntaxerror Oct 12 '14 at 19:52
  • `echo -ne "\x1b[?25h"` fixed a problem for me. Worth making this into an alias and an approved answer. – Daisuke Aramaki Dec 13 '19 at 14:31
5

I don't think making the cursor a vertical line is possible in xterm. It is possible, however, to make it underlined. Just run xterm -uc.

It might be possible to do what you want using another terminal emulator. For example, I use Konsole and I can set the cursor shape to "Block", "I-Beam" and "Underline".

mtvec
  • 17,846
  • 5
  • 52
  • 83
0

This depends on the Terminal emulator you're on.

Try looking at the menu:preferences:Window:cursortype if there's any.

I've seen changing the terminal cursor in Mac/Apple's terminal. Try to see in your linux box.

Neilvert Noval
  • 1,655
  • 2
  • 15
  • 21