Warm tip: This article is reproduced from stackoverflow.com, please click
bash scripting shell vim

Different version of Vim when launching from a Bash script

发布于 2020-04-07 10:15:16

When I run vim --version from a terminal, I see

VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 15 2018 18:27:33)
macOS version
Included patches: 1-280
Compiled by Homebrew

But when I run the same command within a Bash script, I see

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 19 2019 19:08:44)
Included patches: 1-503, 505-680, 682-1283, 1365
Compiled by root@apple.com

The latter version is missing key features, like support for the system clipboard.

In both contexts, whoami returns the same username, and which vim return the same path.

How can I launch the Homebrew version from a script?

Questioner
Bruab
Viewed
59
Philippe 2020-02-08 02:43

This kind of situation often results from having different PATH settings between interactive shell and Bash script, or having an alias or function defined.

A quick way to finding out is to run type -a vim