12

Can I specify my shell for vim? I'm running OS X and have zsh installed via Homebrew and am using MacVim. When I type shell in MacVim, the shell opens up as bash. How can I have it open as zsh?

  • 4
    vim will by default use your system configured shell. I suspect you're running zsh somewhere in your profile or your bash profile. Try running chsh to change your shell on your mac. – mkomitee May 29 '11 at 18:19
  • @mkomitee I wish it did, and vanilla Vim, run from a terminal, does just fine with that. But straight-up, I have MacPorts' Bash set as my shell (verified with chsh), yet MacVim was using /bin/sh when I :shelled out. I thought it could be some weird app security / sandboxing thing with recent versions of macOS, but here is this question from 2011. – TheDudeAbides Nov 26 '19 at 16:39
17

Add or change the following line in ~/.vimrc:

set shell=/path/to/zsh
  • 1
    This doesn't work for me. I specify set shell=/bin/bash in ~/.vimrc, but when I execute :shell and type echo $SHELL output is /bin/zsh. – Daniel Kats Apr 11 '17 at 23:32
3

Not enough reputation for adding a comment, this is meant as a response to @BlackSheep comment in the accepted answer:

Despite the similar syntax, the set shell=/bin/bash does not apply to shell variables, but to variables that are internal to vi, so you can run a shell even if the system's shell for the active user is not a real one.

Also you can use :set shell=/bin/bash then :sh if you don't want to modify ~/.vimrc

  • :sh works for my case. – elquimista Sep 2 '18 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.