8

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

Thomas Dignan
  • 7,052
  • 3
  • 40
  • 48
Stoic
  • 10,536
  • 6
  • 41
  • 60
  • Is your goal to use the colored syntax highlighting _inside_ Vim? – jahroy Oct 17 '12 at 20:27
  • no.. instead, i want to remove all colored syntax (which is present in my login ZSH shell) for the shell command (`:sh`) inside Vim. – Stoic Oct 17 '12 at 20:28
  • GUI Vim (MacVim) or CLI Vim? There's no way to do that in GUI Vim which doesn't have a built-in shell capable of displaying colors and no reason why it should break in CLI Vim. – romainl Oct 17 '12 at 20:40
  • @romainl: MacVim. CLI Vim simply takes me (or atleast makes me feel so) to my terminal, which is perfect. The above issue occurs with MacVim. Can we somehow disable colors for this in MacVim? – Stoic Oct 17 '12 at 20:46
  • Just some thoughts... Doesn't the typical _out of the box .bashrc file_ contain two prompt definitions: one for environments where color is possible and an alternative? I know you're using ZSH, but maybe you can use similar logic to make it so MacVim uses an alternate prompt. – jahroy Oct 17 '12 at 20:52
  • 2
    See this link for some discussion about conditionally executing commands in your _rc file_ when called from Vim: https://github.com/carlhuda/janus/pull/229 See the post by eMxyzptlk at the bottom of the thread... – jahroy Oct 17 '12 at 21:04
  • @jahroy: i was using `bash` for vim shell initially, but switched it to `zsh` because I needed certain functions, aliases, variables that were defined in my ZSH login shell. I guess, I need to import these things into my `.bashrc`, since using `zsh` also breaks `powerline, fugitive, etc.`.. thanks, for the input :) – Stoic Oct 17 '12 at 21:13
  • @Stoic How using `zsh` breaks powerline and fugitive? I use the first, used to try the second and my shell was already zsh when I started using vim. Powerline does not use the shell on its own at all, only through some plugins (including fugitive). Fugitive does not use bash-specific things (all that specifics is for scripting and scripting is already done in VimL). – ZyX Oct 18 '12 at 03:16

1 Answers1

2

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
romainl
  • 186,200
  • 21
  • 280
  • 313