Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZSH - Correct Shell input/output inside Vim / MacVim

Tags:

vim

macvim

zsh

This question is about using MacVim and ZSH on Mac OS X.

I am using ZSH shell and it is configured to use Colored prompt, and everything works nicely with ZSH itself.

However, when I set this shell to be my default with Vim (usin: set shell=zsh\ -li), vim gives me the following symbols when inputting or outputting text:

[35mnikhgupta[00m at [[33mMacbookPro[00m in [01;32m~[00m [00m

while it should simply say:

nikhgupta at MacbookPro in ~

When I input some text, i get the same strange symbols, probably because I am using on the fly syntax highlighting for my ZSH shell. I have deduced that these symbols are color codes?

Can someone help me on how to discard these color codes and simply output text in Vim shell?

Regards

like image 605
Stoic Avatar asked Oct 17 '12 20:10

Stoic


1 Answers

When you do :shell from MacVim, the value of $TERM is set to dumb. You could use that to setup your ZSH environment accordingly.

I'm not familiar with zsh, though, so you will be on your own for writing the correct conditional block. In bash, it would look like that:

if [ $TERM == 'dumb' ];
  then
    echo 'Special setup for MacVim'
fi

Actually, this issue bugged me off for a while so I've just written this for my own use (in bash):

if [ $TERM == 'dumb' ];
  then
    # no colors
    export PS1="\n\w\n\u $ "
  else
    # colors
    export PS1="\n\[\033[32m\]\w\n\[\033[1;31m\]\[\033[1;36m\]\u\[\033[0m\] $ \[\033[0m\]"
fi
like image 77
romainl Avatar answered Oct 18 '22 11:10

romainl