You are not logged in.
Pages: 1
I want to set Vim to desert256 ONLY when using it with gui terminals. How can I tell Vim to use the default with the ttys?
Personally, I'd rather be back in Hobbiton.
Offline
In your vimrc, add something like
if &t_Co == 256 || &t_Co == 88
colorscheme desert256
endif
Last edited by lolilolicon (2009-12-15 03:34:22)
This silver ladybug at line 28...
Offline
I just have vim look for xterm (aren't all terminals based on this?):
if &term=="xterm" " use 256 color palette if available
set t_Co=256
colorscheme wombat256
endif
lolilolicon, what terminal is that for? ... doesn't work on Konsole in KDE.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
@Gen2ly
Probably the t_Co variable is not set in Konsole, but it is set here in urxvt-256color.
:echo &t_Co "echo the value of t_Co
:set termcap "list all termcap info, where you can see if t_Co is set
'term' is not always set to "xterm" for gui terminals. For example, when you use vim inside screen or tmux, it will be set to "screen"; and in my urxvt it is by default set to rxvt-256color. (as per :echo &term)
Maybe it will work better by just testing against "linux", if the t_Co method fails on you (works for me tho, also in tty, where its value is 8).
if &term != "linux"
colorscheme desert256
endif
But this is based on the assumption that tty always sets 'term' as "linux". This I think perhaps is wrong.
And you can also make use of the $COLORTERM variable to identify your terminal too.
So... pick whatever works for you, I'd say.
Last edited by lolilolicon (2009-12-15 12:01:43)
This silver ladybug at line 28...
Offline
...
Maybe it will work better by just testing against "linux", if the t_Co method fails on you (works for me tho, also in tty, where its value is 8).if &term != "linux" colorscheme desert256 endif
But this is based on the assumption that tty always sets 'term' as "linux". This I think perhaps is wrong.
And you can also make use of the $COLORTERM variable to identify your terminal too.
Hmm, good thought, but as you allude to this wouldn't include the terminals that are do have a few odd number color settings (if I remember right urxvt was 192??). I also too found it a little peculiar that "linux" was used since Linux is the kernel, thought it might have to do with an Arch setting.
Never heard of $COLORTERM before...
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
this wouldn't include the terminals that are do have a few odd number color settings (if I remember right urxvt was 192??)
Well as long as the t_Co var is set already and correctly, you can always test it with something like ``if &t_Co >= 88'', if that theme makes sense under 88, 192, foo, bar and what-baz-so-ever.
Whatever works I'd say, again. I can't be confirmed that any of the methods mentioned will 100% work, but combining those tests together may increase your winning chance. For my tty, &t_Co is 8, &term is "linux", and $COLORTERM is not set.
It'd be really nice if someone come and post a killer tester one-liner and say, let's screw all that crap.
Last edited by lolilolicon (2009-12-15 15:45:53)
This silver ladybug at line 28...
Offline
Hi, just to throw in my idea too, it seems like $DISPLAY is always set to something (eg. :0.0) if the term is running under X. On the plain TTYs it's undefined. I tested the following code and it seems to work:
if $DISPLAY != ''
colorscheme desert256
endif
HTH.
Offline
@ Bralkein
Hmm, good thinking as any terminal program will return a $DISPLAY value and console program would not... Ultimately lolilolicon's idea to look for $COLORTERM would be the cover-all solution (as for some instances a user might use more than one terminal that doesn't have 256 color support), but should work for most cases.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Thx, Bralkein's solution worked great.
Personally, I'd rather be back in Hobbiton.
Offline
ignore me, i need to read betters
edit: on a relatedly note, i use this...
" set 256 colors if we can
if $TERM =~ "-256color"
set t_Co=256
colorscheme zenburn
endif
Last edited by brisbin33 (2009-12-17 00:28:09)
//github/
Offline
Pages: 1