bashterminalvitmux

How to change cursor shape depending on Insert or Normal mode when using `set -o vi` in `tmux`?


I would like to use set -o vi in my terminal. However, I find myself getting confused on whether I am in insert mode or normal mode, since the cursor does not switch between a vertical line (insert) and a block (normal). Instead, the cursor is always a block.

I would like it to have a different shape depending on the mode.

This is pretty much the same issue as https://stackoverflow.com/a/48449104/10013420, except with tmux. The solution in the post does not seem to work for tmux.

After setting the ~/.inputrc to what is suggested in the post and launching tmux, the desired effect does not occur.

set -sa terminal-overrides ",xterm*:Ss=\033[6 q:Se=\033[2 q" is something I have tried to add to ~/.tmux.conf, but I did not seem to have much success with it. I obtained the above from AI, which could be dubious.


Solution

  • Try to put this in ~/.vimrc

    let &t_SI = "\e[6 q"
    let &t_EI = "\e[2 q"