changing vim cursor color

1,182 views
Skip to first unread message

Federico Calboli

unread,
Apr 12, 2012, 1:34:15 PM4/12/12
to iterm2-...@googlegroups.com
Hi,

I want to be able to change vim's cursor color (as I did in macvim), but I am utterly failing to achieve this. I set my 'report termianl type' to xterm-256color.

This is my bashrc:

export TERM=xterm-256color
# If running interactively, then:
if [ "$PS1" ]; then

# enable color support of ls and also add handy aliases
# if [ "$TERM" != "dumb" ]; then
alias ls='ls -FG'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias sudo='sudo '
fi

and I added this to .vimrc (though it does not work):

if &term =~ "xterm*\\|rxvt*"
let &t_SI = "\<Esc>]12;sienna\x7"
let &t_EI = "\<Esc>]12;steelblue\x7"
silent !echo -ne "\033]12;red\007"
" reset cursor when vim exits
autocmd VimLeave * silent !echo -ne "\033]112\007"
" use \003]12;gray\007 for gnome-terminal
endif

Any suggestions?

BW

F


--
Federico Calboli
f.ca...@gmail.com

George Nachman

unread,
Apr 13, 2012, 1:33:52 PM4/13/12
to iterm2-...@googlegroups.com
We don't support that escape code, unfortunately. There is another way to do it, though.

Here's the bash command to make the cursor light blue (rgb 4040ff):
echo -e "\033]Pl4040ff\033\\"

Note that this doesn't do anything if you have smart cursor color turned on in prefs->profile->colors.

It is described at the very end of this page: http://www.iterm2.com/#/section/documentation/escape_codes

Federico Calboli

unread,
Apr 14, 2012, 1:49:33 PM4/14/12
to iterm2-...@googlegroups.com
First off apologies for replying to a digest, but the damn google page does not let me post my reply online.

On 14 Apr 2012, at 04:55, iterm2-...@googlegroups.com wrote:

> changing vim cursor color
>
> George Nachman <gnac...@llamas.org> Apr 13 10:33AM -0700

>
> We don't support that escape code, unfortunately. There is another way to
> do it, though.
>
> Here's the bash command to make the cursor light blue (rgb 4040ff):
> echo -e "\033]Pl4040ff\033\\"
>
> Note that this doesn't do anything if you have smart cursor color turned on
> in prefs->profile->colors.
>
> It is described at the very end of this page:
> http://www.iterm2.com/#/section/documentation/escape_codes

This seems to work is somewhat decent way:

if &term =~ "xterm-256color\\|rxvt"
let &t_SI = "\033]Pl4682b4\033\\"
let &t_EI = "\033]Pla0522d\033\\"
silent !echo -ne "\033]Pla0522d\033\\"
autocmd VimLeave * silent !echo -ne "\033]Plc1ffc1\033\\"
endif

the only weird result is that when I close the first instance of vim I get many empty lines.

George Nachman

unread,
Apr 14, 2012, 4:24:07 PM4/14/12
to iterm2-...@googlegroups.com
On Sat, Apr 14, 2012 at 10:49 AM, Federico Calboli <f.ca...@gmail.com> wrote:
First off apologies for replying to a digest, but the damn google page does not let me post my reply online.


Sorry, I had to turn off web posting to reduce spam.
 
This seems to work is somewhat decent way:

if &term =~ "xterm-256color\\|rxvt"
 let &t_SI = "\033]Pl4682b4\033\\"
 let &t_EI = "\033]Pla0522d\033\\"
 silent !echo -ne "\033]Pla0522d\033\\"
 autocmd VimLeave * silent !echo -ne "\033]Plc1ffc1\033\\"
endif

the only weird result is that when I close the first instance of vim I get many empty lines.



Try this:
let &t_ti="\e]Pl4682b4\e\\"
let &t_te="\e]Pla0522d\e\\"

Federico Calboli

unread,
Apr 15, 2012, 8:47:25 AM4/15/12
to iterm2-...@googlegroups.com
On 15 Apr 2012, at 04:15, iterm2-...@googlegroups.com wrote:

>
> George Nachman <gnac...@llamas.org> Apr 14 01:24PM -0700

>
>
> > First off apologies for replying to a digest, but the damn google page
> > does not let me post my reply online.
>
> Sorry, I had to turn off web posting to reduce spam.
>
>

> > endif
>
> > the only weird result is that when I close the first instance of vim I get
> > many empty lines.
>
> Try this:
> let &t_ti="\e]Pl4682b4\e\\"
> let &t_te="\e]Pla0522d\e\\"

The above does NOT work, but the solution seems to be to comment out the line

silent !echo -e "\033]Pla0522d\033\\"

--
Federico Calboli
f.ca...@gmail.com

Reply all
Reply to author
Forward
0 new messages