0

I read Why doesn't .bashrc run automatically? about sourcing .bash_profile from .bashrc and adjusted my config to match this. I am using iTerm2 as my terminal.

Unfortunately, when I do this, my MacVim shell breaks - backspace doesn't work and I have strange characters all over the place. Note the characters?1034h before the prompt and the K that appears when hitting the backspace key.

enter image description here

My .bash_profile:

source ~/.bashrc

My .bashrc:

alias ll='ls -al'
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1

# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color

If copy the settings from .bashrc into .bash_profile and delete .bashrc then the shell in MacVim works fine.

Any idea why MacVim shell breaks sourcing .bash_profile from .bashrc?

  • They look like color codes. – mostruash Dec 29 '16 at 17:52
  • @mostruash I understand what the .bashrc/.bash_profile is doing, I just don't get why sourcing 'bashrc from bash_profile breaks macvim – user783836 Dec 29 '16 at 18:07
  • 1
    before you start macvim what does echo $TERM show in both cases – user151019 Dec 29 '16 at 18:09
  • Also, what does echo $TERM show when called from within the shell spawned by macvim, again in both cases? – nohillside Dec 29 '16 at 18:10
  • I'm just giving a hint, are you sure that you put that CLICOLOR into your bash profile? If you copy bashrc content into bash profile without skipping anything, then I have no idea. Good luck. – mostruash Dec 29 '16 at 18:11
1

According to https://stackoverflow.com/questions/11676026/macvim-shell-sh-only-displays-character-codes-escape-sequences the initial ?1034h characters are the colour codes I've set up in my .bashrc.

When calling echo $TERM from macvim the result is dumb. It looks like the terminal is unable to interpret certain escape sequences.

Details on how to adjust the .bashrc to accommodate (taken from https://stackoverflow.com/a/11676355/783836):

If you would like to use a color prompt on the command line, but not in MacVim you can fix this in ~/.bashrc by setting PS1 differently when inside vim (from [here][1])

if [ $VIM ]; then
        export PS1='\h:\w\$ '
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .