Skip to content

Instantly share code, notes, and snippets.

@asethwright
Created July 8, 2014 15:39
Show Gist options
  • Save asethwright/9c436d2a8a5b0f48e499 to your computer and use it in GitHub Desktop.
Save asethwright/9c436d2a8a5b0f48e499 to your computer and use it in GitHub Desktop.
Vim Cursor Color Change in TMUX
" Cursor to yellow on insert mode
" Blue on command/other mode
" Note the use of hex codes (ie 3971ED)
if exists('$TMUX')
let &t_EI = "\<Esc>Ptmux;\<Esc>\033]Pl3971ED\033\\"
let &t_SI = "\<Esc>Ptmux;\<Esc>\033]PlFBA922\033\\"
silent !echo -ne "\<Esc>Ptmux;\<Esc>\033]Pl3971ED\033\\"
autocmd VimLeave * silent !echo -ne "\<Esc>Ptmux;\<Esc>\033]Pl3971ED\033\\"
else
let &t_EI = "\033]Pl3971ED\033\\"
let &t_SI = "\033]PlFBA922\033\\"
silent !echo -ne "\033]Pl3971ED\033\\"
autocmd VimLeave * silent !echo -ne "\033]Pl3971ED\033\\"
endif
@kostyawhite
Copy link

I've been looking for this a long time, thanks, helped me a lot. Can't figure it out, how to change cursor shape in tmux as well as color, do you have any ideas?

@ozohad
Copy link

ozohad commented Mar 11, 2018

works fine, thx.
how do you add cursor shape change in this line?

@alphaCTzo7G
Copy link

@kostyawhite, @ozohad.. I believe this is based on this answer here: https://vi.stackexchange.com/questions/3756/change-cursor-shape-in-different-terminals

What @asethwright is doing is checking sending the DCS escape sequence, if vim is running in tmux, otherwise the sequcne wont be sent

More details here: http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment