color code in gvim shell

708 views
Skip to first unread message

erich Hoffmann

unread,
Jan 7, 2008, 9:23:01 AM1/7/08
to vim...@googlegroups.com
Hello all.

I googled on this, searched the faq and the vim help, didn't get
further.

When I open a shell with the :shell command in vim, a normal bash shell
is opened and works fine.

But when I open a :shell from within gvim, I get the color codes, which
messes up the display. E.g. I open a shell and close it with exit, it
looks like this:


:shell
[01;31m~ [00m [01;32m\> [00m exite

Then I press return and the shell is closed.

Now with

:!/bin/sh

the shell displays correctly, but without colors. The command
echo $SHELL now yields "/bin/bash". When I now say "bash", the color
codes reappear. With

:!/bin/bash

bash displays the shell messed up with color code instead of colors again.

OK the black-and-white :!/bin/sh is enough for my purposes, but I'd like
to understand. As I said, normal vim displays the shell with colors and
all.

Grateful for any hint,

erch


Tony Mechelynck

unread,
Jan 7, 2008, 11:30:27 AM1/7/08
to vim...@googlegroups.com

Here, ":shell" from Console vim displays colors, from gvim (the same binary,
but using a GUI interface), it doesn't. I think the reason is that Console vim
opens the shell in whatever $TERM it got at startup (such as xterm) while gvim
sets $TERM to "dumb" in the environment it passes to the shell, because the
output to the message-area under the bottom status line cannot move the cursor
upward: in essence, it is limited to the capabilities of a "dumb" terminal
such as a Teletype 33 (printing on paper, which could not be scrolled backward).

BTW, here both bash and sh (when called from gvim) display correctly in black
on white, but "ls --color" in either of them adds color codes messing up the
display.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
218. Your spouse hands you a gift wrapped magnet with your PC's name
on it and you accuse him or her of genocide.

erich Hoffmann

unread,
Jan 7, 2008, 11:45:45 AM1/7/08
to vim...@googlegroups.com
Am Montag, 7. Januar 2008 17:30 schrieb Tony Mechelynck:

> erich Hoffmann wrote:
> >
> > But when I open a :shell from within gvim, I get the color codes, which
> > messes up the display. E.g. I open a shell and close it with exit, it
>
> Here, ":shell" from Console vim displays colors, from gvim (the same
> binary, but using a GUI interface), it doesn't.

Exactly.

>
> I think the reason is that
> Console vim opens the shell in whatever $TERM it got at startup (such as
> xterm) while gvim sets $TERM to "dumb" in the environment it passes to the
> shell, because the output to the message-area under the bottom status line
> cannot move the cursor upward: in essence, it is limited to the
> capabilities of a "dumb" terminal such as a Teletype 33 (printing on paper,
> which could not be scrolled backward).

That explains it. I'm beginning to get the idea.

Thanks to your reply I could google & search better than before.
I did :help term: The gui has a term value called "builtin_gui"
which is built in (that's why it is called so, I guess :). When I
try :set term=$TERM I get a message saying that the gui terminal
cannot be changed.

Found a posting saying the same thing at

http://tech.groups.yahoo.com/group/vim/message/51418

by Bram Moolenaar himself, I cite:

(...)

Starting a shell from within gvim indeed gives you a "dumb" terminal.
Supporting some simple terminal (e.g., a vt52) has been on the todo list
for a while. Including a terminal emulator inside Vim isn't a nice
thing, it makes Vim a bit more bulky. You can do something like
":!xterm -c command" if you need to.

(...)


> BTW, here both bash and sh (when called from gvim) display correctly in
> black on white, but "ls --color" in either of them adds color codes messing
> up the display.

Strange. OK but I have my help. Thanks a lot!


> Best regards,
> Tony.

Best regards to you!

erch

Reply all
Reply to author
Forward
0 new messages