cursor style issue in tmux/vim when using archlinux console

pre

when using a tty console on archlinux, we can’t set the cursor style (like underline or block for example) in a intuitive way like in the GUI based OS where we’re allowed to do the tweak by simply change the setting in the console emulator.
luckily we could use the command echo to achieve the goal.
like the following:

1
echo -e '\e[?6c'

issue

but when running applications like vim or tmux, the cursor reverts back to being a blinking gray underscore.

solution

after searching I found something on the stackexchange.

Most apps use the cnorm capability to set the cursor back to the “normal” state. By default this is the blinking underline. But you can override this in your terminfo. This should fix most applications (vim, tmux, etc.). Issue
ref: How to change cursor shape, color, and blinkrate of Linux Console?

steps

The following should create ~/.terminfo/l/linux which should be picked up by most of the terminal apps.

the following will generate a file which we can use to modify the ~/.terminfo/l/linux later in the current working directory.

1
infocmp -A /usr/share/terminfo linux > linux

according to the following, modify the file.

1
2
3
4
5
6
7
8
9
10
11
12
--- a/linux
+++ b/linux
@@ -4,7 +4,7 @@ linux|linux console,
colors#8, it#8, ncv#18, pairs#64,
acsc=+\020\,\021-\030.^Y0\333\`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\
bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l\E[?1c,
- clear=\E[H\E[J, cnorm=\E[?25h\E[?0c, cr=^M,
+ clear=\E[H\E[J, cnorm=\E[?25h\E[?48;0;32c, cr=^M,
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
EOF

apply the change to the ~/.terminfo/l/linux

1
2
tic linux
rm linux