urxvt tmux vim cursor style issues

331 views
Skip to first unread message

Val

unread,
Aug 16, 2021, 5:41:05 PM8/16/21
to tmux-users

I have the following settings in my .vimrc file which set vertical bar cursor for insert mode, :

       "vertical bar cursor style (insert mode)
        let &t_SI = "\<Esc>[6 q"
        "underline cursor (replace mode)
        let &t_SR = "\<Esc>[4 q"
        "block cursor (default)
        let &t_EI = "\<Esc>[2 q"

These settings work fine if vim is started in xterm, xterm -> tmux or urxvt terminal. However, the cursor doesn't change if I start vim from urxvt -> tmux sessition.
I've seen suggestions to use the following vim settings for tmux:

        let &t_SI .= "\<Esc>Ptmux;\<Esc>\<Esc>[6 q\<Esc>\\"
        let &t_SR .= "\<Esc>Ptmux;\<Esc>\<Esc>[4 q\<Esc>\\"
        let &t_EI .= "\<Esc>Ptmux;\<Esc>\<Esc>[2 q\<Esc>\\"

The above works, but the problem is that the cursor is not saved/restored when I move between panes/windows. Its style changes globally. Once I enter vim insert mode, the cursor changes to bar, and stays like that in all windows/panes.

If I set TERM to xterm-256color instead of  rxvt-unicode-256color, the cursor works fine, just like in xterm -> tmux session. however, there's a problem with F1-F4 keys, since urxvt uses different key mappings for them.

So it looks like tmux is the culprit in this vim cursor issue. Somehow tmux decides not to support cursor capabilities in the urxvt terminal.

For example, `echo -ne "\e[6 q"` works fine in urxvt, xterm, xterm->tmux sessions, but doesn't work in urxvt->tmux.

Please, help.

Nicholas Marriott

unread,
Aug 16, 2021, 5:46:49 PM8/16/21
to Val, tmux-users
If the TERM outside tmux doesn't describe the cursor style sequences and tmux can't detect they are supported itself then it won't use them. Try:

set -as terminal-features 'rxvt*:cstyle'



--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/ce2eeefa-2b35-4206-90cf-cf1bf542a34dn%40googlegroups.com.

Val

unread,
Aug 16, 2021, 6:13:49 PM8/16/21
to tmux-users
Thank you very much! This option does the trick on the latest tmux. Is there any equivalent for the older versions (before 3.1)?
BTW, how should the TERM describe the cursor style sequences for tmux to detect them?
The urxvt does support them, but somehow tmux doesn't see it.

Nicholas Marriott

unread,
Aug 16, 2021, 6:16:06 PM8/16/21
to Val, tmux-users
you can use terminal-overrides on older tmux, you want to set Ss and Se, look at what they are set to on a new tmux with "tmux info" from inside tmux



Nicholas Marriott

unread,
Aug 16, 2021, 6:18:13 PM8/16/21
to Val, tmux-users
set -as terminal-overrides 'rxvt-unicode*:Ss=\E[%p1%d q:Se=\E[2 q'

Val

unread,
Aug 16, 2021, 6:33:20 PM8/16/21
to tmux-users
Thank you! That worked like a charm.
Somehow Ss and Se are missing from the default tmux info. Probably something is wrong with rxvt term caps.
Reply all
Reply to author
Forward
0 new messages